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
https://forums.phpfreaks.com/topic/219535-redirect-using-session/
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>

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.