I have an issue that's driving me crazy, perhaps someone here can be of help. I'm putting together my church's website and I recently moved the files from one hosting account to another. I had a bunch of user authentication on the site that used sessions that worked fine on the old hosting account but just stopped working once I moved all the files over to the new hosting account. After some troubleshooting, I narrowed the issue down to the session variables not saving correctly when I navigate to different pages. I've included a simple, two page snippet of code below.
-----------------PAGE 1: -------------------------
Code: Select all
<?
session_start();
$var1 = "Chris";
$_SESSION["username"]=$var1;
?>
<?=$_SESSION["username"]?> is the username stored in the session.</br>
<a href="test2.php">click</a>
Chris is the username stored in the session.
click
As you can see from the output above, the session variable is stored and can be retrieved on the first page. So, I click on where it says click and page 2 looks like below:
-----------------PAGE 2: -------------------------
Code: Select all
<?
session_start();
?>
<?=$_SESSION["username"]?> is the username stored in the session.</br>
is the username stored in the session.
At this point $_SESSION["username"] is gone. If I store something in a session, shouldn't it be available to me throughout the entire session on the site until I specifically drop or destroy the session? Does this have anything to do with settings in the php.ini? The fact that it was working under my old hosting account but not working under my new one makes me think that it might. Please help!