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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.