Jump to content

help with redirection


icon

Recommended Posts

hi


i have made a site which uses mysql with sessions, but what i wont to know is i have the following code:

<?

if(!$_SESSION['username']){

header("Location: [a href=\"http://domain");\" target=\"_blank\"]http://domain");[/a]

} else {

print <<<END

html

END;
}
?>



on the page to protect and if there is no session name in the current session it redirect to the login page how do i have a query string added to the url that send it back to the page it come from like ie domain.com/bahbah/?url=http://home.domain.com

thanks
Link to comment
Share on other sites

what you say is exactly right...

just add

?url=http://www....whatever

or you could even just use php server variable to get the referring page.

I like to add an error variable on to saty something like
[code]
$error_explain="Your Session has timed out.  Please log back in.";

header("Location: http://domain/login.php?url=http://referrer&amp;error=$error_explain");
[/code]
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.