Re: [PHP] unregister part of array in session

2001-04-16 Thread Yasuo Ohgaki
PHP4 session may not work as it should, unless you use it consistent way.

i.e. Use session_(un)register() and only use globals, OR enable track_vars and
disable register_globals and only use $HTTP_SESSION_VARS w/o
session_(un)register(). It may work even if register_globals is on. I didn't
test session module with this configuration enough.

Following code works as expected on my systems (PHP4.0.4-PHP4.0.5RC1/Apache
SAPI/W2K and PHP4.0.4-PHP4.0.4RC6/Apache SAPI/Linux at least)

=== code begin ===



Session Test



1, 'b'=>2 );
 print_r($HTTP_SESSION_VARS);
}
elseif (isset($HTTP_GET_VARS['b'])) {
 unset($HTTP_SESSION_VARS['a']['a']);
 print_r($HTTP_SESSION_VARS);
}
else {
 print_r($HTTP_SESSION_VARS);
}
?>



 code end 

It should work as expected when you enable track_vars AND disable
register_globals in your php.ini.

The reason why there is session_register()/unregister() is there is no way for
session module to know which variables are session variables. With
$HTTP_SESSION_VARS, session module knows all variable in $HTTP_SESSION_VARS are
session variables. So programmer does not have to use session_(un)register().

There is also known problem that $HTTP_SESSION_VARS does not work like other
$HTTP_*_VARS. You will see what I mean if you write some test codes with
register_globals = on.

I don't know why many people use
register_globals = on
track_vars = off
magic_quote = on

Life would be much easier with
register_globals = off
track_vars = on
magic_quote = off

Hope this helps,
--
Yasuo Ohgaki


""Tobias Talltorp"" <[EMAIL PROTECTED]> wrote in message
9bempj$a77$[EMAIL PROTECTED]">news:9bempj$a77$[EMAIL PROTECTED]...
> I did it!
> Too much work for something as simple as this though IMO. I think I will
> write a function for this...
>
>  session_start();
> $newarray = $HTTP_SESSION_VARS["array"];
> unset ($newarray["one"]);
> $array = $newarray;
> session_register("array");
> ?>
>
> Thanks,
> // Tobias
>
>
> ""Yasuo Ohgaki"" <[EMAIL PROTECTED]> wrote in message
> 9bdeag$88r$[EMAIL PROTECTED]">news:9bdeag$88r$[EMAIL PROTECTED]...
> > You are registered $array as session,
> > You need to unset() element. I think it should work.
> >
> > Regards,
> > --
> > Yasuo Ohgaki
> >
> >
> > ""Tobias Talltorp"" <[EMAIL PROTECTED]> wrote in message
> > 9bd8un$kqt$[EMAIL PROTECTED]">news:9bd8un$kqt$[EMAIL PROTECTED]...
> > > I know how to unset a specific value in an ordinary array:
> > > unset ($array["one"]);
> > > How do I do this if my array is in a session?
> > >
> > > Here is my code:
> > >  > > session_start();
> > > $array = array(one=> "number one", two=> "Number two", three=> "Number
> > > three");
> > > session_register("array");
> > > ?>
> > >
> > > I tried this... Didn't work:
> > >  > > session_start();
> > > session_unregister("array[one]");
> > > ?>
> > >
> > > Thanks,
> > > // Tobias Talltorp
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Re: [PHP] unregister part of array in session

2001-04-16 Thread Tobias Talltorp

I did it!
Too much work for something as simple as this though IMO. I think I will
write a function for this...



Thanks,
// Tobias


""Yasuo Ohgaki"" <[EMAIL PROTECTED]> wrote in message
9bdeag$88r$[EMAIL PROTECTED]">news:9bdeag$88r$[EMAIL PROTECTED]...
> You are registered $array as session,
> You need to unset() element. I think it should work.
>
> Regards,
> --
> Yasuo Ohgaki
>
>
> ""Tobias Talltorp"" <[EMAIL PROTECTED]> wrote in message
> 9bd8un$kqt$[EMAIL PROTECTED]">news:9bd8un$kqt$[EMAIL PROTECTED]...
> > I know how to unset a specific value in an ordinary array:
> > unset ($array["one"]);
> > How do I do this if my array is in a session?
> >
> > Here is my code:
> >  > session_start();
> > $array = array(one=> "number one", two=> "Number two", three=> "Number
> > three");
> > session_register("array");
> > ?>
> >
> > I tried this... Didn't work:
> >  > session_start();
> > session_unregister("array[one]");
> > ?>
> >
> > Thanks,
> > // Tobias Talltorp
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] unregister part of array in session

2001-04-15 Thread Brian Clark


@ 8:18:31 PM on 4/15/2001, Brian Clark wrote:

...
> Why not save the values to a temp variable, destroy the session,
> unset the value you want to unset, then register it again?

Well I take that back. Read the first two comments here:

http://www.php.net/manual/en/function.session-unset.php

By doing what I originally suggested, I guess they'd end up with a
different session, which isn't what you want obviously.

-Brian
--
 PGP is spoken here: 0xE4D0C7C8
 Please, DO NOT carbon copy me on list replies.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] unregister part of array in session

2001-04-15 Thread Yasuo Ohgaki
You are registered $array as session,
You need to unset() element. I think it should work.

Regards,
--
Yasuo Ohgaki


""Tobias Talltorp"" <[EMAIL PROTECTED]> wrote in message
9bd8un$kqt$[EMAIL PROTECTED]">news:9bd8un$kqt$[EMAIL PROTECTED]...
> I know how to unset a specific value in an ordinary array:
> unset ($array["one"]);
> How do I do this if my array is in a session?
>
> Here is my code:
>  session_start();
> $array = array(one=> "number one", two=> "Number two", three=> "Number
> three");
> session_register("array");
> ?>
>
> I tried this... Didn't work:
>  session_start();
> session_unregister("array[one]");
> ?>
>
> Thanks,
> // Tobias Talltorp
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Re: [PHP] unregister part of array in session

2001-04-15 Thread Brian Clark

Hi Tobias,

@ 7:01:41 PM on 4/15/2001, Tobias Talltorp wrote:

...
> I tried this... Didn't work:
>  session_start();
> session_unregister("array[one]");
?>>

Why not save the values to a temp variable, destroy the session, unset
the value you want to unset, then register it again?

-Brian
--
 PGP is spoken here: 0xE4D0C7C8
 Please, DO NOT carbon copy me on list replies.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] unregister part of array in session

2001-04-15 Thread Tobias Talltorp

I know how to unset a specific value in an ordinary array:
unset ($array["one"]);
How do I do this if my array is in a session?

Here is my code:
 "number one", two=> "Number two", three=> "Number
three");
session_register("array");
?>

I tried this... Didn't work:


Thanks,
// Tobias Talltorp




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]