Re: [Q] session variables wouldn't keep contents.
| From: | Chung Ha-Nyung | Date: | Tue, 13 Mar 2001 07:45:37 +0000 |
| Subject: | Re: [Q] session variables wouldn't keep contents. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43734@lists.php.net to get a copy of this message | ||
>>>>> "YO" == Yasuo Ohgaki <yohgaki@hotmail.com> writes:
YO> ----- Original Message -----
YO> From: "Chung Ha-Nyung" <alita@kldp.org>
YO> To: <php-general@lists.php.net>
YO> Sent: Tuesday, March 13, 2001 3:19 PM
YO> Subject: [PHP] [Q] session variables wouldn't keep contents.
>
> Hi guys,
>
> Some php programs doesn't seem to work normally in a certain
> server. Those wokred correctly in my Debian box.
> Session is the problem.
YO> The code seems wrong. Although, it can work. It depends on php.ini.
>
> It seems that the contents of session variables disappears after
> reloading the php page. Here is the program.
>
> ---- test.php ----
>
>
> <?php
> session_start();
YO> You must start session before output anything to browser, or you must use
YO> buffering to do this,
YO> or you must use URL mode for session.
YO> i.e. This code sends "<html><body>" before starting session and
YO> cookie header
YO> must be sent before if session is cookie mode.
YO> I recommend to write session_start() before programmers do anything.
I modified that way. But no effect. still not work correctly.
After reloading, session variables are emptied. ;(
> if(!session_is_registered("name")) {
> ";
> session_register("name");
> $HTTP_SESSION_VARS["name"] = "test";
> ";
>
> $session_name = $HTTP_SESSION_VARS["name"];
> ";
> echo "session_name = $session_name";
>
>
>
> ---- test.php ----
>
> Can I handle it with only php configuration file? Or Do I have to
> modify my php programs?
YO> I'm not sure what do you want to handle "it".
Just *poor* english. ;P
solving the above trouble.
YO> Starting session can handle in php.ini and inside code.
>
> In addition to this, I have a few questions about the work of session
> in php 4.0.4
>
> Q1) Do I have to use session_start() explicitly although session.auto_start
> is set to 1 in php.ini?
YO> No.
YO> Session will be started automatically, so programmer does not have to write it.
YO> I recommend to write session_start(), though.
YO> Also, session will be started implicitly if programmer uses session functions
YO> even without setting session.auto_start to true. It should work, if programmer
YO> didn't send any output to browser before. i.e. Programmer does not even have to
YO> write session_start() even if session.auto_start is false. I don't recommend it,
YO> though.
> Q2) Do I have to use session_register("variable_name")?
> In my Debian woody box, it seems to run well without it.
YO> It seems works fine on my box without it when I use $HTTP_SESSION_VARS at least.
YO> I think it will not work without $HTTP_SESSION_VARS.
YO> (PHP4.0.4pl1/Apache/RedHat Linux7)
I use only $HTTP_SESSION_VARS. ;)
YO> Regards,
YO> --
YO> Yasuo Ohgaki
--
Chung Ha-Nyung <alita@kldp.org>