Jump to content

small php sessions issue (I'm hoping)


DamienRoche

Recommended Posts

Ok, so on the surface this seems quite simple.

 

I have registered 3 session variables using session_start and $_SESSION....blah blah

 

I have put the session start at the very beginning of the page before any headers.

<?php session_start();

 

Now, the session variables are registering and i'm able to pass them onto other pages quite easily. The problem I am having is that when I press the back button on the browser, the session is somehow destroyed, or so I assume.

 

There is nothing wrong with the syntax, I haven't used session_destroy(); yet and I have included session_start in every page before the headers...I'm hoping this isn't unavoidable.

 

Any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/122582-small-php-sessions-issue-im-hoping/
Share on other sites

From what I gather, I don't think you need a session on each and every page, just the start when you create the $_SESSION[]

 

from then on you can call $_SEESION[] at any point. To actually kill the session

 

<?php
session_start();
$_SESSION = array();
session_destroy();
?>

I need the session_start(); on every page the session is involved in because that continues the session.

 

I don't want to kill the session, quite the opposite. When I press back button on the browser, the session variables are lost. any ideas?

That depends on how your client goes 'back'

 

Some clients will store the page in cache, and hitting back will NOT reload the page, but simply display the version stored on the local machine.

 

Other cases may be the client sending the same header information when the back button is pushed, and the session cookie may not have been included in those headers.

 

Try disabling caching on the client - there are some headers that will do this for you... but this isn't a guaranteed fix as the effect is client-side.

 

http://www.anyexample.com/programming/php/completely_disable_any_browser_caching.xml

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.