Author Topic: PHP Session Management  (Read 6508 times)


  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1612
    • Precision Solutions
PHP Session Management
« on: May 09, 2008, 05:06:41 PM »
Stumbled upon something interesting.  In PHP we have session_start() to start a session, but there's no session_end() or session_close() that closes up everything nice and neat.  Yes, there is a session_destroy() which removes the server side variables, but ... it leaves the client cookie intact!  So if you need to close up both sides of the session - and hey why not? - try this:

function session_close()
    setcookie(session_name(),false);  // Kill the cookie on the client
    session_destroy();                     // ...then kill the server side info
« Last Edit: July 20, 2008, 12:11:36 PM by precisonline »
Accidents "happen"; success, however, is planned and executed.