8 Responses to “PHP login handling tutorial – sessions & cookies included”

  1. Kenny Khoo says:

    I am try to run the code. but the error say there is a missing function of:
    1. add_session()
    2. remove_session()
    3. get_session()
    Any idea? Thank 1st. :)

  2. admin says:

    add_session(a,b) and set_session(a,b) both do $_SESSION[a]=b;
    get_session(a) returns $_SESSION[a];
    remove_session(a) does unset($_SESSION[a]);

    In some systems where customers are paranoid about XSS attacks I can replace $_SESSION with something else and I don’t have to change thousands of references in my code.

    Thanks! You’re the first real person to comment on this blog. Hooray for you! :)

  3. Kenny Khoo says:

    Thank, How about account_login() function? it is to clear all cookie and close session?

  4. admin says:

    account_login() creates the cookie/session data to remember that you are logged in. At the end of account_login() is where you would add any extra commands – maybe a “welcome, user!” message or redirect to a different page.

  5. houari says:

    How about add_notice() and add_error() functions?

  6. admin says:

    I’ve written a new, easier version with better code and examples. Please let me know if that helps!

    http://www.marginallyclever.com/2009/09/forms-simplified/

  7. houari says:

    Admin, your answer was about another script, can you put the full code of your login handling, please.

    because I’ve not suc when i try to showing notices on the login page.

  8. Chris says:

    Thanks for the source. Couldn’t find the “new, easier version”. But the current one seems to work just fine for my purposes

Leave a Reply