Re: Sharing variable values among PHP files

From: Date: Tue, 01 Apr 2003 16:28:00 +0000
Subject: Re: Sharing variable values among PHP files
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-26796@lists.php.net to get a copy of this message
Hi Leston In case Leif, doesn't get back to you, here's a way to do it (inline). Similar to what Mustafa has already posted:- On 01 Apr,2003 at 8:35 Leston Drake wrote: <snip> > For us novices, can you please share how you would do this with > register_globals off? > </snip> <snip> > >><?php > >> > >>// need this on all pages where you want to work with // the session var > >>session_start(); > >> > >>// Check for the existence of the session var and create > >>// it if it doesn't exist > >>if (!session_is_registered("ses_username")) { </snip> // Check if session var is set if (!isset($HTTP_SESSION_VARS["ses_username"])) { // check to see if we have a posted var from form if (isset($HTTP_POST_VARS["frm_username"])) { // We have no session var and a form var // waiting for us $HTTP_SESSION_VARS["ses_username"]=$HTTP_POST_VARS["frm_username"]; } } // Now $HTTP_SESSION_VARS["ses_username"] exists and contains // the username <snip> > >> session_register("ses_username"); > >>} > >> > >>// Are we getting a form var thru ? if so pop it into the session > >>var </snip> You can shorten $HTTP_SESSION_VARS to $_SESSION if PHP version > 4.1.0. Cheers -- Ronan e: ronan@thelittledot.com t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley

« previous php.db (#26796) next »