Jump to content


Photo

Can't share SESSION variables. I need some help!


  • Please log in to reply
4 replies to this topic

#1 mmtalon

mmtalon
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 19 April 2006 - 09:03 AM

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:

<?php
session_start();
// page1.php
$_SESSION['grncolor'] = 'green';
echo $_SESSION['grncolor']; // output works here
echo session_id(); // outputs session_id
// passing the session id - also tried absolute path with same results
echo '<br /><a href=\"../AA_dir/page2.php?' . SID . '\">page 2</a>';
?>

<?php
session_start();
// page2.php
//tried if(isset($_SESSION['grncolor'])) { negative }
echo $_SESSION['grncolor']; // green - will not output a value
echo session_id(); // outputs same session_id as in page1.php
echo '<br /><a href="../BB_dir/page1.php">page 1</a>';
?>


#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 10:09 AM

This works for me. You seemed to have un-necessary bits in there.


<?php
session_start();
// page1.php
$_SESSION['grncolor'] = 'green';
echo $_SESSION['grncolor']; // output works here
echo session_id(); // outputs session_id
// passing the session id - also tried absolute path with same results
echo '<br /><a href=../bb/page2.php>page 2</a>';
?>


<?php
session_start();
// page2.php
//tried if(isset($_SESSION['grncolor'])) { negative }
echo $_SESSION['grncolor']; // green - will not output a value
echo session_id(); // outputs same session_id as in page1.php
echo '<br /><a href="../aa/page1.php">page 1</a>';
?>
wisewood: proven fact, I am both wise, and wooden.

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 19 April 2006 - 03:00 PM

[!--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.
~ D Kuang

#4 mmtalon

mmtalon
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 19 April 2006 - 05:41 PM

[!--quoteo(post=366445:date=Apr 19 2006, 10:00 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 19 2006, 10:00 AM) View Post[/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.


#5 mmtalon

mmtalon
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 20 April 2006 - 03:22 PM

[!--quoteo(post=366513:date=Apr 19 2006, 12:41 PM:name=mmtalon)--][div class=\'quotetop\']QUOTE(mmtalon @ Apr 19 2006, 12:41 PM) View Post[/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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users