Re: playing with sessions... (fwd)
| From: | Jani Taskinen | Date: | Mon, 26 Nov 2001 15:16:13 +0000 |
| Subject: | Re: playing with sessions... (fwd) | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71661@lists.php.net to get a copy of this message | ||
This was with PHP 4.1.0RC3? All this should be fixed in HEAD.
_IF_ I understood the problem correctly.
--Jani
On Mon, 26 Nov 2001, Derick Rethans wrote:
>Forwarding to PHP DEV...
>
>(Oh, php 4.1.0 is already packed, and will be announced later today by
>Zeev iirc).
>
>Derick
>
>---------- Forwarded message ----------
>Date: Mon, 26 Nov 2001 10:13:54 +0000
>From: Hellekin O. Wolf <hellekin@php.net>
>To: php-qa@lists.php.net
>Subject: [PHP-QA] playing with sessions...
>
>Hello,
>
>an overview of sessions in 4.1.0RC3 (compiled with --enable-trans-sid)
>
>-> register_globals = off
>
>session_is_registered() will return true but $_SESSION and
>$HTTP_SESSION_VARS are empty.
>This is unusable.
>
>-> register_globals = on + session.use_cookie = off
>
>Loose session when used on multiple pages. Single page works OK.
>This configuration requires setting "?".session_name()."=".session_id() on
>links for multiple pages sessions.
>
>-> register_globals = on + session.use_cookie = on
>
>Works well with both single and multiple pages (if the client accepts cookies).
>Warning for those used to register_globals = off :
> *ALL* session variables should be registered just after session_start().
> If you don't do that, you may set a global $var that will OVERRIDE
>$_SESSION['var']
> which is not true with register_globals = off.
>
>Example :
>
><?php
>
>session_start();
>if (!session_is_registered('count')) session_register('count');
>if (!session_is_registered('test')) session_register('test');
>
>$count = NULL; // Will override $_SESSION['count'] !!!
>// Instead you have to do :
>$test = $_SESSION['test']; // which is empty by default, overriding any
>globals sent by client.
>
>echo ++$count.":".++$test;
>?>
>
>or you can use :
>
><?php
>
>/* this was adapted from the manual */
>function session_init_var($var,$val) {
> if (!session_is_registered($var)) {
> global $var;
> $var = $val;
> return session_register($var);
> }
>}
>
>?>
>
>hellekin
>
>
>