suttercain Posted May 1, 2007 Share Posted May 1, 2007 Hi guys, I am trying to take the current directory path (http://www.domain.com/news.php?id=27) and store it in a session to process on a new page. I am using: <?php $_SESSION['address'] = dirname($_SERVER['PHP_SELF']); ?> and this to try and echo it on the new page: <?php $address = $_SESSION['address']; echo "Site Address: " . $address; ?> But the only thing echoed is "/" What is the easiest way to store the full web page URL into a session? Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/49489-solved-current-web-page-path-stored-in-a-session/ Share on other sites More sharing options...
taith Posted May 1, 2007 Share Posted May 1, 2007 <? function get_url(){ if(!empty($_SERVER['QUERY_STRING'])) return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; else return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; } $_SESSION[address]=get_url(); echo $_SESSION[address]; ?> Link to comment https://forums.phpfreaks.com/topic/49489-solved-current-web-page-path-stored-in-a-session/#findComment-242567 Share on other sites More sharing options...
suttercain Posted May 1, 2007 Author Share Posted May 1, 2007 Perfect!!! Thank you! Link to comment https://forums.phpfreaks.com/topic/49489-solved-current-web-page-path-stored-in-a-session/#findComment-242574 Share on other sites More sharing options...
taith Posted May 1, 2007 Share Posted May 1, 2007 no prob :-) that one also saves $_GET[] querys... if you didnt catch that Link to comment https://forums.phpfreaks.com/topic/49489-solved-current-web-page-path-stored-in-a-session/#findComment-242576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.