RE: [PHP] session data missing

2003-07-14 Thread Ford, Mike [LSS]
> -Original Message-
> From: ulf sundin [mailto:[EMAIL PROTECTED]
> Sent: 13 July 2003 23:37
> 
> I'm not the admin on the server, so I'll have to manage with 
> the software
> provided. And that is php 4.0.6.

Ah, right.  Me, too, actually, which is why I still have the 4.0.6 manual on
my PC!

> I've tried a number of ways to store variables in the session 
> file. This
> works:
> 
> session_start();
> $foo = 'bar';
> session_register('foo');
> 
> then after session_write_close(); or end of script:
> echo $HTTP_SESSION_VARS['foo']; will output 'bar'.
> 
> just adding variables directly into the HTTP_SESSION_VARS 
> array won't make
> them stick in the session file.

No, I wouldn't expect them to as the manual explicitly says they won't.

>  Use of session_register() seems to be
> required.

Yes. I'd expect that too -- the 4.0.6 manual is again quite clear that you
can only get variables into your session with session_register().

What it's not so clear about is whether

   session_register('foo');
   $HTTP_SESSION_VARS['foo'] = 'bar';

will set the session variable foo to 'bar' under all circumstances -- it
im-plies that it should when register_globals is off, but is very ambiguous
about exactly what  happens when register_globals is on.

Thanks for the heads-up on this topic -- I'm just about to start writing
some code which will make heavy use of sessions, and initially it will have
to work for version 4.0.6 (until my site admin decides to upgrade), so I
guess I've got some heavy testing in prospect on my test server to work out
exactly what all the combinations do -- I need to write stuff that will work
regardless of register_globals, and will continue to work unchanged when the
eventual upgrade to 4.3.x comes along.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



Re: [PHP] session data missing

2003-07-13 Thread ulf sundin
I'm not the admin on the server, so I'll have to manage with the software
provided. And that is php 4.0.6.
I've tried a number of ways to store variables in the session file. This
works:

session_start();
$foo = 'bar';
session_register('foo');

then after session_write_close(); or end of script:
echo $HTTP_SESSION_VARS['foo']; will output 'bar'.

just adding variables directly into the HTTP_SESSION_VARS array won't make
them stick in the session file. Use of session_register() seems to be
required.

Ulf

"Mike Ford" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> > -Original Message-
> > From: Kevin Stone [mailto:[EMAIL PROTECTED]
> > Sent: 09 July 2003 20:30
> >
> > - Original Message -
> > From: "ulf sundin" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, July 09, 2003 1:00 PM
> > Subject: Re: [PHP] session data missing
> >
> >
> > > ok, so now the variable names are registred and stored in
> > the file. But
> > > without values.
> > > check this:
> > >
> > > --firstpage.php
> > > session_start()
> > > session_register('foo');
> > > $HTTP_SESSION_VARS['foo'] = 'bar';
> > > echo $HTTP_SESSION_VARS['foo']; //outputs bar;
> > >
> > > transport by a href to:
> > > secondpage.php
> > > session_start();
> > > echo $HTTP_SESSION_VARS['foo']; //outputs nothing
> > >
> > > ---
> > > checking the contents of the file called /tmp/sess_{session_id}:
> > >  !foo|
> > (snip)
> >
> >
> > Make a choice here..
> >
> > => session_register('foo');
> > => $HTTP_SESSION_VARS['foo'] = 'bar';
> >
> > Use either the session_register() function or the session
> > global array.  Not
> > both.
>
> Not true -- $HTTP_SESSION_VARS is *not* like $_SESSION, and its values are
*not* auto-registered.  In fact, I still have my copy of the 4.0.6 manual
around, and it specifically gives this as an example:
>
> > Example 1. Registering a variable
> >
> >  > session_register("count");
> > $HTTP_SESSION_VARS["count"]++;
> > ?>
>
> However, it's a little unclear on whether this should still work
regardless of the register_globals setting, as it also gives this as an
example:
>
> > Example 2. Registering a variable with register_globals enabled
> >
> >  > session_register("count");
> > $count++;
> > ?>
>
> I guess I'd have to go away and try it to be sure of what behaviour occurs
for each setting of register_globals -- but there seems little point given
that using $_SESSION has been much the best option for several versions now!
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211



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



RE: [PHP] session data missing

2003-07-11 Thread Ford, Mike [LSS]
> -Original Message-
> From: Kevin Stone [mailto:[EMAIL PROTECTED]
> Sent: 09 July 2003 20:30
> 
> - Original Message -
> From: "ulf sundin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 09, 2003 1:00 PM
> Subject: Re: [PHP] session data missing
> 
> 
> > ok, so now the variable names are registred and stored in 
> the file. But
> > without values.
> > check this:
> >
> > --firstpage.php
> > session_start()
> > session_register('foo');
> > $HTTP_SESSION_VARS['foo'] = 'bar';
> > echo $HTTP_SESSION_VARS['foo']; //outputs bar;
> >
> > transport by a href to:
> > secondpage.php
> > session_start();
> > echo $HTTP_SESSION_VARS['foo']; //outputs nothing
> >
> > ---
> > checking the contents of the file called /tmp/sess_{session_id}:
> >  !foo|
> (snip)
> 
> 
> Make a choice here..
> 
> => session_register('foo');
> => $HTTP_SESSION_VARS['foo'] = 'bar';
> 
> Use either the session_register() function or the session 
> global array.  Not
> both.

Not true -- $HTTP_SESSION_VARS is *not* like $_SESSION, and its values are *not* 
auto-registered.  In fact, I still have my copy of the 4.0.6 manual around, and it 
specifically gives this as an example:

> Example 1. Registering a variable 
> 
>  session_register("count");
> $HTTP_SESSION_VARS["count"]++;
> ?>

However, it's a little unclear on whether this should still work regardless of the 
register_globals setting, as it also gives this as an example:

> Example 2. Registering a variable with register_globals enabled 
> 
>  session_register("count");
> $count++;
> ?>

I guess I'd have to go away and try it to be sure of what behaviour occurs for each 
setting of register_globals -- but there seems little point given that using $_SESSION 
has been much the best option for several versions now!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] session data missing

2003-07-09 Thread ulf sundin
ok. now I get it. first set the session-variables like any other:
$foo = 'bar';
then register them in the sessionfile:
session_register('foo');

that makes sense. But it's not at all what the manual says. I guess my php
version has passed its expiration date.

thanks for the help, anyway. It seems to be working the way I wanted it to.

Regards
Ulf

"Kevin Stone" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
>
> - Original Message -
> From: "ulf sundin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 09, 2003 1:00 PM
> Subject: Re: [PHP] session data missing
>
>
> > ok, so now the variable names are registred and stored in the file. But
> > without values.
> > check this:
> >
> > --firstpage.php
> > session_start()
> > session_register('foo');
> > $HTTP_SESSION_VARS['foo'] = 'bar';
> > echo $HTTP_SESSION_VARS['foo']; //outputs bar;
> >
> > transport by a href to:
> > secondpage.php
> > session_start();
> > echo $HTTP_SESSION_VARS['foo']; //outputs nothing
> >
> > ---
> > checking the contents of the file called /tmp/sess_{session_id}:
> >  !foo|
> (snip)
>
>
> Make a choice here..
>
> => session_register('foo');
> => $HTTP_SESSION_VARS['foo'] = 'bar';
>
> Use either the session_register() function or the session global array.
Not
> both.
>
> - Kevin
>
>



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



Re: [PHP] session data missing

2003-07-09 Thread Kevin Stone

- Original Message -
From: "ulf sundin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 1:00 PM
Subject: Re: [PHP] session data missing


> ok, so now the variable names are registred and stored in the file. But
> without values.
> check this:
>
> --firstpage.php
> session_start()
> session_register('foo');
> $HTTP_SESSION_VARS['foo'] = 'bar';
> echo $HTTP_SESSION_VARS['foo']; //outputs bar;
>
> transport by a href to:
> secondpage.php
> session_start();
> echo $HTTP_SESSION_VARS['foo']; //outputs nothing
>
> ---
> checking the contents of the file called /tmp/sess_{session_id}:
>  !foo|
(snip)


Make a choice here..

=> session_register('foo');
=> $HTTP_SESSION_VARS['foo'] = 'bar';

Use either the session_register() function or the session global array.  Not
both.

- Kevin



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



Re: [PHP] session data missing

2003-07-09 Thread ulf sundin
ok, so now the variable names are registred and stored in the file. But
without values.
check this:

--firstpage.php
session_start()
session_register('foo');
$HTTP_SESSION_VARS['foo'] = 'bar';
echo $HTTP_SESSION_VARS['foo']; //outputs bar;

transport by a href to:
secondpage.php
session_start();
echo $HTTP_SESSION_VARS['foo']; //outputs nothing

---
checking the contents of the file called /tmp/sess_{session_id}:
 !foo|

I guess it should be something like !foo=bar|

but, as I said, the values doesnt seem to stick in the file, just the names
of the variables.

I must be doing something wrong.

Regards
Ulf


"Mike Ford" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> > -Original Message-
> > From: ulf sundin [mailto:[EMAIL PROTECTED]
> > Sent: 09 July 2003 01:01
> >
> > After creating a new session with session_start() and
> > inserting a few values
> > e.g $HTTP_SESSION_VARS['foo'] = 'bar'; a file
> > /tmp/sess_{session_id} is
> > created.
> > The problem is that this file is empty! 0 bytes. no data is stored.
> > I'm using php 4.0.6 on linux with apache 1.3 something.
>
> Just doing session_start() will create the file.  Are you also
> session_register()-ing your session vars?  The $HTTP_SESSION_VARS array
> isn't like the $_SESSION array introduced in PHP 4.1 -- it's values are
not
> automatically registered.  You still have to use session_register(), thus:
>
> session_start();
> session_register('foo');
> $HTTP_SESSION_VARS['foo'] = 'bar';
>
> HTH
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211



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



RE: [PHP] session data missing

2003-07-09 Thread Johnson, Kirk
> After creating a new session with session_start() and 
> inserting a few values
> e.g $HTTP_SESSION_VARS['foo'] = 'bar'; a file 
> /tmp/sess_{session_id} is
> created.
> The problem is that this file is empty! 0 bytes. no data is stored.
> I'm using php 4.0.6 on linux with apache 1.3 something.

Check the register_globals setting in php.ini. If it is set to "On", then
code like this:

session_start();
$foo = 'bar';
session_register('foo');
echo $foo;

If register_globals is set to "Off", then code as you are already doing:

session_start();
$HTTP_SESSION_VARS['foo'] = 'bar';
echo {$HTTP_SESSION_VARS['foo']};

Kirk

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



RE: [PHP] session data missing

2003-07-09 Thread Ford, Mike [LSS]
> -Original Message-
> From: ulf sundin [mailto:[EMAIL PROTECTED]
> Sent: 09 July 2003 01:01
> 
> After creating a new session with session_start() and 
> inserting a few values
> e.g $HTTP_SESSION_VARS['foo'] = 'bar'; a file 
> /tmp/sess_{session_id} is
> created.
> The problem is that this file is empty! 0 bytes. no data is stored.
> I'm using php 4.0.6 on linux with apache 1.3 something.

Just doing session_start() will create the file.  Are you also
session_register()-ing your session vars?  The $HTTP_SESSION_VARS array
isn't like the $_SESSION array introduced in PHP 4.1 -- it's values are not
automatically registered.  You still have to use session_register(), thus:

session_start();
session_register('foo');
$HTTP_SESSION_VARS['foo'] = 'bar';

HTH

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



[PHP] session data missing

2003-07-08 Thread ulf sundin
After creating a new session with session_start() and inserting a few values
e.g $HTTP_SESSION_VARS['foo'] = 'bar'; a file /tmp/sess_{session_id} is
created.
The problem is that this file is empty! 0 bytes. no data is stored.
I'm using php 4.0.6 on linux with apache 1.3 something.

Regards
Ulf



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