Jump to content

[SOLVED] Page History Problems


gazalec

Recommended Posts

Hi i have a little problem, on my website I allow users to enter the website as a guest or login, and if they continue as a guest they have the option to login on every page, the only problem is if they login they go to the login page after logging in they are directed to the welcome page again i was wondering if there was a way for them to login and return to the previous page, i know if could create a login page for every page and redirect them to each relative page but that would just be so inefficient i was just wondering if there was a way to attach the page (filename) to a session or cookie etc.

 

Thanks in advance

 

P.S I am currently using the header script to relocate them

 

header("Location:welcome.php")

Link to comment
https://forums.phpfreaks.com/topic/42833-solved-page-history-problems/
Share on other sites

On every page, add:

$_SESSION['login_ref'] = basename($_SERVER['PHP_SELF']);

 

Then redirect them to that var:

header("Location: ".$_SESSION['login_ref']);

 

This assumes that all of the files are in the same folder. Make the adjustments needed if you have different folders. Also, make sure you use session_start() on every page.

 

Orio.

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.