mmtalon Posted April 19, 2006 Share Posted April 19, 2006 Can't share SESSION variables. I need some help! Don't understand why this isn't working. Perhaps it is because I have the 2 files in 2 different directories? My register_globals is Off Code example: <?phpsession_start();// page1.php$_SESSION['grncolor'] = 'green';echo $_SESSION['grncolor']; // output works hereecho session_id(); // outputs session_id// passing the session id - also tried absolute path with same resultsecho '<br /><a href=\"../AA_dir/page2.php?' . SID . '\">page 2</a>';?> <?phpsession_start();// page2.php//tried if(isset($_SESSION['grncolor'])) { negative }echo $_SESSION['grncolor']; // green - will not output a valueecho session_id(); // outputs same session_id as in page1.phpecho '<br /><a href="../BB_dir/page1.php">page 1</a>';?> Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 This works for me. You seemed to have un-necessary bits in there.<?phpsession_start();// page1.php$_SESSION['grncolor'] = 'green';echo $_SESSION['grncolor']; // output works hereecho session_id(); // outputs session_id// passing the session id - also tried absolute path with same resultsecho '<br /><a href=../bb/page2.php>page 2</a>';?> <?phpsession_start();// page2.php//tried if(isset($_SESSION['grncolor'])) { negative }echo $_SESSION['grncolor']; // green - will not output a valueecho session_id(); // outputs same session_id as in page1.phpecho '<br /><a href="../aa/page1.php">page 1</a>';?> Quote Link to comment Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This works for me. You seemed to have un-necessary bits in there[/quote]No, that's not un-necessary. That will propagate the session ID if the user disables cookies.If it's outputting the same session id, I have really no idea on whats wrong. Quote Link to comment Share on other sites More sharing options...
mmtalon Posted April 19, 2006 Author Share Posted April 19, 2006 [!--quoteo(post=366445:date=Apr 19 2006, 10:00 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 19 2006, 10:00 AM) [snapback]366445[/snapback][/div][div class=\'quotemain\'][!--quotec--]No, that's not un-necessary. That will propagate the session ID if the user disables cookies.If it's outputting the same session id, I have really no idea on whats wrong.[/quote]Thanks for the replies wisewood and poirot. I have checked the session id, which is spitting out the same id. I was thinking maybe I had missed some setting of some kind - e.g. php.ini etc. or maybe it's my ISP. Tell me if I could be overlooking something. Also if you create your own sessions, how often do you use them and are they hard to construct?Again, thanks a lot for your help. Quote Link to comment Share on other sites More sharing options...
mmtalon Posted April 20, 2006 Author Share Posted April 20, 2006 [!--quoteo(post=366513:date=Apr 19 2006, 12:41 PM:name=mmtalon)--][div class=\'quotetop\']QUOTE(mmtalon @ Apr 19 2006, 12:41 PM) [snapback]366513[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks for the replies wisewood and poirot. I have checked the session id, which is spitting out the same id. I was thinking maybe I had missed some setting of some kind - e.g. php.ini etc. or maybe it's my ISP. Tell me if I could be overlooking something. Also if you create your own sessions, how often do you use them and are they hard to construct?Again, thanks a lot for your help.[/quote]I found out that I am overlooking something. It has something to do with my code and how it's structured. I know this after testing with 2 files that I created having just the essentials. The stripped down code worked and let me know that the problem is within my code somewhere.Thanks for all the input. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.