Link to home
Start Free TrialLog in
Avatar of rkmarthy
rkmarthy

asked on

How can I destroy session variable when IE is closed

I have some shopping cart type application and I am using session variables to store users actions. I need to destroy session variables when user closes browser with out signing out. In the logout script I am using session_destroy() to end session. But How can I end when a browser window is closed? Also can anyone suggest how to clear session variables and cookies after certain period of time?
ASKER CERTIFIED SOLUTION
Avatar of Klodorff
Klodorff

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shmert
shmert

By default, the PHP session cookie expires when the user closes his browser.  The file used to store the session information for a single session is periodically removed automatically if the user exits without terminating the session.  It's probably safe to just not worry about terminating the session.
Avatar of rkmarthy

ASKER

I set the sessions as per your code... its working. But the sessions, even though I am closing the browser I can still access the session variables. But when I am loggin out I am using session_destroy() so the session is getting ended??? Any idea
perfect guys... its working now for me... session is getting ended when I am closing the browser... Thanks a lot for guiding me...
no problem rkm.
glad we solved it