Jump to content

last visited page


zang8027

Recommended Posts

I dont know if this is javascript or what but is there a way to make a link back to the previous page you were on? Right now, I have a page that checks to see if your logged in using php. If not, it sends you to a sign in page. That uses PHP to sign you in and redirect you to the index page. But I would like to have it redirect to the page you where just on. Any way to do this?

 

ATM i use the php command

 

header(Location:../index.php); to send it back to the page.

Link to comment
https://forums.phpfreaks.com/topic/141640-last-visited-page/
Share on other sites

You use PHP for this...

 

When the user goes to a page that is restricted, before you redirect them to the login page, put the page in a session variable:

//session_start(); //Session should already be started from the code you use to validate if they are logged in
$_SESSION['last_page'] = $_SERVER['REQUEST_URI'];

then do your redirect to login.php

header('Location: login.php');
exit;

then, after they login successfully, you can redirect them:

$redirect = $_SESSION['last_page'] ? $_SESSION['last_page'] : 'index.php';
header('Location: '.$redirect');
exit;

Link to comment
https://forums.phpfreaks.com/topic/141640-last-visited-page/#findComment-741426
Share on other sites

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.