Jump to content

Browser and $_SESSION data now I remember it now I don't behavior


jayteepics

Recommended Posts

This problem happens in both IE9 and Chrome 13.0.782.112 m on Windows

 

If I close the browser down, my session data is gone on browser restart, if however I just close the tab leaving other tabs say with BBC news and restart my app in a new tab, both browsers remember the old session data.

 

Since the intended user could do this at any time before completing a transaction, I don't actually get a chance to destroy the session this only happens if they complete payment for their order via..

  session_destroy();
  $conn->commit();
  $conn->autocommit(TRUE);

 

In an attempt to clean up I tried various combinations at the top of the start page "index.php"..

 

  session_start();
//  $_SESSION = array();
  session_destroy($_SESSION['cart']);
  session_destroy($_SESSION['address']);
//  $_SESSION['cart'] = array();
//  $_SESSION['address'] = array();
//  session_destroy();

 

Can anyone please shed any light on this behaviour difference?

 

Jamie

 

Link to comment
Share on other sites

It's browser behavior. When a cookie is created with no expire time, the browser should expire it when the window is closed. From what I can tell, the behavior of most browsers is to not see a tab being closed as a trigger to expire that cookie.

 

There's no real way to end a session when a tab closes without relying on JavaScript.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.