Re: session management

From: Date: Wed, 09 Aug 2000 13:15:23 +0000
Subject: Re: session management
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-10913@lists.php.net to get a copy of this message
caused by expire of session variable ? default expire time is 24 mins > Mark Faine wrote: > > > Maybe you need to do a session_start(); > > or turn on auto session start in php.ini > > more than likely it is something to do with your configuration > > I have cracked the problem with some code from webmonkey: > > session_start(); > > if(!$PHPSESSID) { > session_register("ARRAY"); > $ARRAY = array(); > } elseif(!$ARRAY) { > $ARRAY = array(); > } > > Anyway, thanks very much for your help - my brain is slowly solidifying again > ;) > > Regards, > > Richard > > "I'm tired of ... I'm tired of travelling, I'm tired of doing commedy. I'm > tired of looking out at your vacant faces looking back at me, wanting me to > fill your empty lives with humour you couldn't possibly think of yourselves." > Bill Hicks > > > > -----Original Message----- > > From: Richard Jones [mailto:rikki@ultramail.co.uk] > > Sent: Tuesday, August 08, 2000 9:27 AM > > To: Mark Faine > > Subject: Re: [PHP] session management > > > > Mark Faine wrote: > > > if(!isset($SESSION)){ > > > session_register("SESSION"); > > > } > > > > > > $SESSION is an array, and is now registered > > > > I've just tried this, and am still turning up the same problem. It seems > > to > > > > be that the $SESSION variable is simply not being passed between successive > > loads of the page, which is odd, 'cos I tried the counting script on: > > http://www.php.net/manual/ref.session.php and that worked > > fine. > > I have both register_globals and track_vars turned on, which I thought was > > all that was required to get sessions to work OK. I don't have to pass > > $SESSIONS back to the page every time it loads, do I? That's what session > > management is for, isn't it? > > > > > You should read the documentation on sessions, also phpbuilder has a lot > > > > of > > > > > good articles, and web monkey as well. > > > > I've looked at the documentation on sessions for more time than I care to > > remember, but I'll have a go at the others, cheers. > > > > BTW, is there any sort of protocol for responding to emails on this list > > (ie, > > replying at the top, and leaving the original at the bottom)? > > > > Thanks for your help > > > > Richard > > > > > > "I hate patriotism, man, it makes me ... sick. It's a round world last > > time > > > > I checked" > > Bill Hicks > > > > > "Richard Jones" <rikki@ultramail.co.uk> wrote in message > > > news:00080813240602.10895@arthur... > > > > > > > Hello all, > > > > > > > > I've just joined the mailing list, and am already wondering if someone > > > > can help me. I am attempting to use an array as a session variable. > > > > About an hour ago, it was working OK. It had some bugs, but in general > > > > it was > > > > > > doing > > > > > > > what I wanted. Feeling satisfied with my progress I take a break for a > > > > cigarette, during which time the code decides that actually, it's not > > > > > > going > > > > > > > to work after all!! > > > > > > > > I'm sure that I didn't touch anything between when it worked and didn't > > > > > > work > > > > > > > - my only guess is that maybe something was being cached somewhere, to > > > > > > hide > > > > > > > the fact that I'd broken it, but that it's quite unlikely. > > > > > > > > I wrote: > > > > > > > > file://session management gumpf > > > > > > > > session_start(); > > > > session_register($ARRAY); > > > > > > > > > > > > /* check that the array has been set. If not, set it */ > > > > > > > > if(!isset($ARRAY) || !is_array($ARRAY)) { > > > > $ARRAY = array(); > > > > echo "reset"; // just so I can see when it's doing this > > > > } > > > > > > > > include("products.php"); // other functions are contained in here > > > > > > > > /* check that $pta (a number) is set. If it is, and $amount (another > > > > number) is not set, then set $amount to 1, and then build the array */ > > > > if(isset($pta)) { > > > > if (!isset($amount)) { > > > > $amount = 1; > > > > } > > > > $ARRAY = build_cart_array($CART, $pta, $amount); // this works, and > > > > $ARRAY is returned as a successfully built array. > > > > } > > > > > > > > // end of session management gumpf > > > > > > > > > > > > The problem seems to be that further down the page that this is at the > > > > top of, I call other functions which use $ARRAY. They all also > > > > manipulate the array correctly, but some of them require that the page > > > > on > > > > > > which the above code is stored be reloaded. Now, that /was/ OK until > > > > after my cigarette, > > > > > > and > > > > > > > everything behaved nicely, but suddenly the array checking code that > > > > > > prints > > > > > > > "reset" every time it runs is running every time that I reload the > > > > page, > > > > > > and > > > > > > > resets the array to being empty, which is not what I want. > > > > > > > > My suspicions concern the session_register() function. I've read that > > > > it > > > > > is > > > > > > > buggy (I don't know how true this is), and that it overwrites all > > > > session > > > > > > variables when it runs. If this is the case, does anyone know how to > > > > get > > > > > > round it, and any ideas why it wasn't causing problems before? Any > > > > help would be thoroughly appreciated, as I've been banging my head > > > > against it > > > > > > for > > > > > > > some time now, and my brain is hurting. > > > > > > > > Cheers, > > > > > > > > Richard > > > > > > > > "I need my sleep. I need eight hours a day ... and about ten at > > > > night." Bill Hicks > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > To contact the list administrators, e-mail: > > > > php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#10913) next »