note 8704 added to Session handling functions
| From: | davidgindelberger at yahoo dot com | Date: | Mon, 25 Sep 2000 12:24:57 +0000 |
| Subject: | note 8704 added to Session handling functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-5363@lists.php.net to get a copy of this message | ||
Newbie note: I wanted to track sessions using PHP4's built in session handling routines using
NT4.0 SP6+ Apache + MySQL. I got a simple MySQL auth script working, but couldn't get the damn
session variables made available to pages other than the page where
session_register("varname") was used.
this is what worked in short:
page 1:
1) Do the MySQL thing
2) check to see if I get a result back
3) no - sorry bub no can do!
4) Yep - welcome back old friend!
session_start(); //NOT start_session()!!
session_register("name");
session register("time");
//etc.
$sid = session_id();
header ("Location: main.php?SID=$sid");
//pass the sid to the next page, not sure if the SID=$sid is necessary now, but I'll leave it
in anyway.
page 2:
session_start(); <-REQUIRED! on every page though?
echo $name;
echo $GLOBALS["name"];
//both seem to work, but not without the session_start()! argh, this was frustrating, but I am
pretty new to php. The fun is in the learning! This stuff is way cool.
http://www.php.net/manual/ref.session.php