My cookies settings in Firefox & IE are to accept cookies from everyone, including 3rd parties and to keep them until they expire. I have used test scripts to check if sessions are working on my computer (the script is in the 3rd code block) and it shows that sessions are working (i double checked the tmp folder and a cookie has been created as well). I don't think there's anything wrong with the code, but possibly some sort of setting that will not allow session variables to be defined... i'm lost. I'm using WAMP with winXP and have php5.2.9 & apache2.2.11 installed. I've tried searching the net, but can't find an answer. If anyone could help me figure out why this might be happening it would be a BIG help. Thanks.
Code: Select all
<? php
session_start();
$_SESSION['username'] = 'Joe12345';
$_SESSION['authuser'] = 1;
?>
<html>
<head>
<title>Find my Favorite Movie!</title>
</head>
<body>
<?php
$myfavmovie = urlencode('Life of Brian');
echo "<a href=\"moviesite.php?favmovie=$myfavmovie\">";
echo 'Click here to see information about my favorite movie!';
echo '</a>';
?>
</body>
</html>Code: Select all
<? php
session_start();
//check to see if user has logged in with a valid password
if ($_SESSION['authuser'] != 1)
{
echo 'Sorry, but you don\'t have permission to view this page!';
exit();
}
?>
<html>
<head>
<title>My Movie Site - <?php echo $_GET['favmovie']; ?></title>
</head>
<body>
<?php
echo 'Welcome to our site, ';
echo $_SESSION['username'];
echo '! <br/>';
echo 'My favorite movie is ';
echo $_GET['favmovie'];
echo '<br/>';
$movierate = 5;
echo ' My movie rating for this movie is: ';
echo $movierate;
?>
</body>
</html>Code: Select all
<?php
session_start(); // the FIRST THING YOU DO!
// to see sessions "not work", comment out the "session_start();" line
if (!isset($_SESSION['test'])) {
echo "First activation: setting session variable";
$_SESSION['test'] = 1;
} else
echo "SESSIONS ARE WORKING! activation: ", (++$_SESSION['test']);
?>