Page 1 of 1
Calling URL - How?
Posted: Thu Nov 13, 2008 4:25 pm
by oscardog
Well i know its using the $_SERVER command, but i've been looking on the web and most sites just tell me its crap. I only want it for a simple job, basically if they came from logout.php , echo "You are now logged out" above the login form..
So, how do i get the URL in which they came from? Cos i obv dont want the message displayed if theycame from index.php.
Thanks!
Re: Calling URL - How?
Posted: Thu Nov 13, 2008 7:00 pm
by chopsmith
If you are just trying to find the URL of the page from which the user came, you should be able to use $_SERVER['HTTP-REFERER']. See
http://us2.php.net/manual/en/reserved.v ... server.php.
However, I don't think this is what you really want to do. If you have a logout.php script, that script, once visited, should probably just unset any $_SESSION variables you have set to maintain state. Or, if you're using cookies directly, the logout.php script should just destroy those cookies.
Not sure exactly what you want to do and/or how you're doing everything else, but I think you should look into $_SESSION variables.
Re: Calling URL - How?
Posted: Thu Nov 13, 2008 9:16 pm
by John Cartwright
chopsmith wrote:If you are just trying to find the URL of the page from which the user came, you should be able to use $_SERVER['HTTP-REFERER']. See
http://us2.php.net/manual/en/reserved.v ... server.php.
However, I don't think this is what you really want to do. If you have a logout.php script, that script, once visited, should probably just unset any $_SESSION variables you have set to maintain state. Or, if you're using cookies directly, the logout.php script should just destroy those cookies.
Not sure exactly what you want to do and/or how you're doing everything else, but I think you should look into $_SESSION variables.
$_SERVER['HTTP_REFERER'] should never be relied upon. It is up to the user client to send it's referal url, and is often blocked or manipulated to protect the users privacy. Instead, as chopsmith suggested, store the last visited page in a session variable.