SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Good to unset $_SESSIon befoer destroying it?

    In many examples I have seen, when a user logs out, each thing in a session is unset (ex. unset($_SESSION['email']))and then the session is destroyed (ex. session_destroy()).

    What is the purpose of unsetting a session's elements if you are just going to destroy the session itself anyway?

  2. #2
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because the session is still accessible on the same page load.

    For example:
    Code:
    session_start();
    
    $_SESSION['blah'] = 'adsf';
    
    session_destroy();
    
    echo $_SESSION['blah'];

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just found that out while running tests. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •