Jump to content

Setting a session to store user's last page visited?


Solarpitch

Recommended Posts

 

Hi Guys,

 

I have the following code that sets a session to return the user back to the previous page they were on.

 

$_SESSION['last_page'] = (!isset($_SESSION['curr_page'])) ? "http://www.mydomain.com/page1.php" : $_SESSION['curr_page'];
$_SESSION['curr_page'] = $_SERVER['PHP_SELF'];

 

Bascially I am looking for a better way to do this. The problem with this is you need to hard code what the previous page was.

 

Is there anyway to dynamically set what page the user was on. What if the last page URL had an id in it like...

 

http://www.mydomain.com/?id=14

 

How could I set this as the previous page in a session?

 

 

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.