Re: Sharing variable values among PHP files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux