session error
Posted: Tue Sep 15, 2009 8:25 am
consider the following code..
filename movie1.php
now consider the following code
filename moviesite.php
why the value of authuser is not found in the 2nd file ???
filename movie1.php
Code: Select all
<?php
session_start();
$_SESSION['username'] ="lipun4u";
$_SESSION['authuser'] = 1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled Document</title>
</head>
<body>
<?php
$movie=urlencode("Die another day");
echo "<a href='http://127.0.0.1/moviesite.php?favmovie=$movie'>";
echo "Click here to see the information about my favorite movie";
echo "</a>";
?>
</body>
</html>
filename moviesite.php
Code: Select all
<?php
session_start();
//echo ($_SESSION['authuser']);
if($_SESSION['authuser'] != 1) {
echo "Sorry, you don't have permission to view this page";
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>My movie site - <?php echo $_REQUEST['favmovie']?></title>
</head>
<body>
<?php
echo ("Welcome to our site, ");
echo ( $_SESSION['username']);
echo (" <br>\n");
echo "My favorite movie is ";
echo $_REQUEST['favmovie'] ;
echo "<br>";
$movierate=5;
echo "My movie rating for this movie is : ";
echo $movierate;
?>
</body>
</html>