Re: HELP: USING $_SESSION instead of session_register()

From: Date: Fri, 29 Mar 2002 06:15:50 +0000
Subject: Re: HELP: USING $_SESSION instead of session_register()
Groups: php.windows 
Request: Send a blank email to php-windows+get-12813@lists.php.net to get a copy of this message
Not quite... Here's something that ought to work better for you: ----page1------ <? session_start(); if (!isset($_SESSION['foo'])) { $_SESSION['foo'] = "test foo"; } ?> <body> <? echo $_SESSION['foo'] . "<br>"; echo session_id() . "<br>"; echo "<br><br>"; ?> <a href="reg_2.php">reg_2.php</a> </body> ----page2-------- <? session_start(); ?> <body> <? print $_SESSION['foo']."<br>"; ?> </body> ----Original Message Follows---- From: "Bossanova" <pootri@hotmail.com> To: <php-windows@lists.php.net> Subject: [PHP-WIN] HELP: USING $_SESSION instead of session_register() Date: Thu, 28 Mar 2002 13:06:55 -0800 Pardon my ignorance, I've been searching for answers for this new $_SESSION to work to no avail. If someone can help me out by giving examples how I can pass the session_id to the next page and access the same $_SESSION["var"] on that page, it would be very helpful. My question is, once I set this on the 1st page: <? session_start(); if (!isset($_SESSION["foo"])) { $_SESSION["foo"] = "test foo"; } ?> <body> <? echo $_SESSION["foo"] . "<br>"; echo session_id() . "<br>"; echo "<br><br>"; ?> <a href="reg_2.php?id="<? session_id(); ?>">reg_2.php</a> </body> How do I set up link to the next page, and what should I put on the next page? Will this be correct? <? session_id($_GET["PHPSESSID"]); session_start(); ?> <body> <? print $_SESSION["foo"]."<br>"; ?> </body> But I got this error message: Warning: Undefined index: foo in c:\phps\reg_2.php on line 6 I'm new to PHP so this is also a major factor of the failure. Again, thanks for your help. Burhan greg wrote: ------------------------------- Use of $_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended for security and code readablity. With $_SESSION or $HTTP_SESSION_VARS, there is no need to use session_register()/session_unregister()/session_is_registered() functions. Users can access session variable like a normal variable. http://www.php.net/manual/en/ref.session.php _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com

« previous php.windows (#12813) next »