Re: I did: Re: session_start

From: Date: Sat, 14 Dec 2002 13:00:50 +0000
Subject: Re: I did: Re: session_start
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-128284@lists.php.net to get a copy of this message
On Saturday 14 December 2002 17:19, John Taylor-Johnston wrote: > I did call session_start() before anything is output to the browser. > http://www.php.net/manual/en/function.session-start.php > > I only have one php file so I know I'm recyling my code each time: > > session_name("TestALS"); > session_start(); > > session_register("studentid"); > if (isset($_SESSION["studentid"])) > { > $id = $_SESSION["studentid"]; > echo "\$studentid= $studentid<br>"; > } RTFM again. Sessions depends on a number of factors including your version of PHP and the setting of register_globals. Basically if you're going to be using $_SESSION then you don't use session_register(). You just assign the value directly to $_SESSION. <?php // test-session.php session_start(); if (!isset($_SESSION['studentid'])) { $_SESSION['studentid'] = 24; } if (isset($_SESSION['studentid'])) { $_SESSION['studentid']++; $id = $_SESSION['studentid']; echo "\$id= $id<br>"; } ?>

« previous php.general (#128284) next »