Jump to content

Redirect using session


doddsey_65

Recommended Posts

Ok so a user tries to access a part of the site that requires them to login. So they are taken to the login page. but when they login I want them transfered to the page they were going to. So i thought of something like:

 

<a href="securepage.php" onClick="<?php echo $_SESSION['clicked_link'] = $site_root.'securepage.php'; ?>">
Click Here
</a>

 

But when I echo $_SESSION['clicked_link'] not only am i getting the url i am getting the content after.

 

echoed it looks like:

 

http://www.thevault.cz.cc/securepage.php">Click Here

 

So is there a better way to do it? if not what would i need to do to remove everything after the " ?

Link to comment
Share on other sites

i am saving the url to a session and when it redirects me to the login page i am echoing thesession for debugging and it looks fine. It displays the url.

 

However when i login the session is destroyed and echoes nothing. Thus my header redirect does nothing. Any ideas why the session is being destroyed?

 

This is an example of a link that you can click which needs you to be logged in. If you arent then you are redirected to the login page where i am echoing the session:

 

<a href="'.$site_root.'/profile.php?user='.$forum_info->user_id.'" title="Visit '.$forum_info->user_username.'\'s Profile" 
onClick="'.$_SESSION["clicked_link"] = $site_root.'/profile.php?user='.$forum_info->user_id.'">'.$forum_info->user_username.'</a>

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.