Hey folks;
I have PHP session variables that are having some troubles. I posted in a few other forums but couldn't really find one dedicated to my specific issue. I am using a few session variables throughout my website and am using the following two lines at the top of every session related page:
[php]
<?php
session_start() ;
$_SESSION['userID'] = ""; //initialization on first page used only
?>
[/php]
and then code elsewhere on the page. In every case, the session variable saves fine and works. UNTIL it swaps pages. When the 2nd page is loaded I was using "echo $_SESSION['<name>']" but in every case again, the $_SESSION variable loses the data that was set in code and reverts to whatever it was initialized to (using the above example: if the $_SESSION['userID'] saved "Bob123" on page 1, now it would have " " saved).
I had originally hardcoded values in to move on with development but now I need to get this working and am frustrated with the lack of help search engines and other resources have provided. Thanks in advance for any assistance any of you here in the community can provide.
- LB
I have PHP session variables that are having some troubles. I posted in a few other forums but couldn't really find one dedicated to my specific issue. I am using a few session variables throughout my website and am using the following two lines at the top of every session related page:
[php]
<?php
session_start() ;
$_SESSION['userID'] = ""; //initialization on first page used only
?>
[/php]
and then code elsewhere on the page. In every case, the session variable saves fine and works. UNTIL it swaps pages. When the 2nd page is loaded I was using "echo $_SESSION['<name>']" but in every case again, the $_SESSION variable loses the data that was set in code and reverts to whatever it was initialized to (using the above example: if the $_SESSION['userID'] saved "Bob123" on page 1, now it would have " " saved).
I had originally hardcoded values in to move on with development but now I need to get this working and am frustrated with the lack of help search engines and other resources have provided. Thanks in advance for any assistance any of you here in the community can provide.
- LB
Comment