SN1P3R_85 Posted September 2, 2008 Share Posted September 2, 2008 I posted about this earlier today, and i think i went about explaining my problem the wrong way. I want to redirect one of my pages to a another page, but i stored the location in a variable. On a previous page i stored the url by doing this: $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; Now after the user does something, it should redirect them back to that page. I am not sure how to include the variable in the location. I've tried this, and it doesn't redirect at all. $url = $_SESSION['return_url']; header("Location: $url"); Basically, i just need to know how to use a variable instead of a direct url. Also, if you know a better way to store a url than this, go ahead and tell me: $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; Link to comment https://forums.phpfreaks.com/topic/122454-header-syntax-help/ Share on other sites More sharing options...
trq Posted September 2, 2008 Share Posted September 2, 2008 Nothing wrong with the syntax your using as long as you have session_start() in place wherever your using the $_SESSION array. You might also try echo'ing $url to see that it is a valid url. Link to comment https://forums.phpfreaks.com/topic/122454-header-syntax-help/#findComment-632286 Share on other sites More sharing options...
SN1P3R_85 Posted September 2, 2008 Author Share Posted September 2, 2008 i tried echoing it, and i got nothing, so maybe its not valid. Do you know a good way to get the url of the current page you're on. In the format so i can just stick it in the header like this: header("Location: $url"); Link to comment https://forums.phpfreaks.com/topic/122454-header-syntax-help/#findComment-632287 Share on other sites More sharing options...
SN1P3R_85 Posted September 2, 2008 Author Share Posted September 2, 2008 I store the session exactly like this: <?php session_start(); $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; ?> Is this the wrong way? how long do sessions last? i thought they lasted until the person left the website. Link to comment https://forums.phpfreaks.com/topic/122454-header-syntax-help/#findComment-632306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.