Ok, here's the deal:
I've created three pages to help me learn sessions.
Page one: index.php
Page two: page2.php
Page three: page3.php
I'll be blunt: I am totally and utterly confused.
The example, http://www.flamehtmlstudios.com/session/.
Ok, here's the code.
Index.php is
just a simple form that submits the person's name to page2.php, which is:
Now, the issue here is that $name is not showing as the person's name, but rather, literally, "$name". Why is this?!PHP Code:<?php
// PAGE2.PHP
ini_set("bug_compat_42" , "off");
ini_set("session.bug_compat_warn" , "off");
$name = $_REQUEST['name'] ;
if(!$name) {
$name = "You4gotAName";}
setcookie('name' , $name);
session_start();
$_SESSION['name'] = $name ;
?>
<html>
<head>
<title>Session Practice, Page 2</title>
</head>
<body>
<a href="page3.php"><?php echo $name ?>, Go To Page 3</a>.
</body>
</html>
Ok, so, the $name is issue is the same for page3.php, which is below:
Ok, again, the $name issue is present here.PHP Code:<?php
// PAGE3.PHP
ini_set("bug_compat_42" , "off");
ini_set("session.bug_compat_warn" , "off");
$name = $_COOKIE['name'];
if(!$_COOKIE['name']) {
echo "No Name" ;}
session_start();
$_SESSION['name'] = $name ;
echo "
<html>
<head>
<title>Session Practice, Page 2</title>
</head>
<body>
You've reached the end of the line, $name"."!
</body>
</html> ";
unset($_SESSION['name']) ;
?>
Also, I know I'm supposed to end the session.
How do I do this?
Now, I'm so confused.
First of all, I know I probably don't need the cookie stuff in there at all, since PHP automatically drops a cookie, and if cookies aren't enabled, puts a file with the session id on the server, correct?
Ok, some help here?!
![]()



Reply With Quote


Bookmarks