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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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