----- Original Message -----
From: "Chung Ha-Nyung" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 13, 2001 3:19 PM
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.
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 ----
> <html>
> <body>
> <?php
> session_start();
You must start session before output anything to browser, or you must use
buffering to do this,
or you must use URL mode for session.
i.e. This code sends "<html><body>" before starting session and cookie header
must be sent before if session is cookie mode.
I recommend to write session_start() before programmers do anything.
> if(!session_is_registered("name")) {
> echo "session is not registered<br><br>";
> session_register("name");
> $HTTP_SESSION_VARS["name"] = "test";
> echo "newly registered<br><br>";
> }
> $session_name = $HTTP_SESSION_VARS["name"];
> echo session_encode()."<br><br>";
> echo "session_name = $session_name";
> ?>
> </body>
> </html>
> ---- test.php ----
>
> Can I handle it with only php configuration file? Or Do I have to
> modify my php programs?
I'm not sure what do you want to handle "it".
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?
No.
Session will be started automatically, so programmer does not have to write it.
I recommend to write session_start(), though.
Also, session will be started implicitly if programmer uses session functions
even without setting session.auto_start to true. It should work, if programmer
didn't send any output to browser before. i.e. Programmer does not even have to
write session_start() even if session.auto_start is false. I don't recommend it,
though.
> Q2) Do I have to use session_register("variable_name")?
> In my Debian woody box, it seems to run well without it.
It seems works fine on my box without it when I use $HTTP_SESSION_VARS at least.
I think it will not work without $HTTP_SESSION_VARS.
(PHP4.0.4pl1/Apache/RedHat Linux7)
Regards,
--
Yasuo Ohgaki
>
> Regards,
>
> --
> Chung Ha-Nyung <[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]