FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » session_start() should return FALSE but does not
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: session_start() should return FALSE but does not [message #170294 is a reply to message #170292] Wed, 27 October 2010 10:10 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 27/10/2010 9:49, Rene escribió/wrote:
> I have played around with session_start() and found in the php manual,
> that session_start() returns FALSE when php failed to start the
> session (in php>= 5.3.0). So I took a php6dev (quite old from March)
> and wrote the following script:
>
> <?php
> if (version_compare(phpversion(), '5.3.0')>= 0) {
> if (session_start() == TRUE) {
> echo "Session successfully started\n";
> echo $_SESSION['check'] . "\n<br>";
>
> $_SESSION['check'] = "Session works";
> }
> else
> echo "Session could not be started!\<br>";
> }
> phpinfo();
> ?>
>
> This script should return "session works" when the script is loaded
> the second time. This works fine. Then I added a space in the first
> line to trigger an error. This is what I got:
>
> Warning: session_start() [function.session-start]: Cannot send session
> cookie - headers already sent by (output started at ******/
> test.php6:2) in /******/test.php6 on line 4
>
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at ******/
> test.php6:2) in ******/test.php6 on line 4
> Session successfully started
>
> A reload does not lead to the message "Session works" so I assume that
> the session has not been created successfully although session_start()
> returns TRUE. Unfortunately, this old version of php6 is the only one
> that I have available that is>=5.3.0. Is that fixed in later
> versions? Does it work as expected in 5.3.0? Am I wrong somewhere?

The manual page does not state what "successfully started" means. I've
been testing it myself in PHP/5.3.3 under Windows XP and I've been
unable to make it return FALSE. It returns TRUE when it starts a new
session, it returns TRUE when it resumes a previous session, it returns
TRUE when session_start() was already called, it returns TRUE when the
session directory does not exist... If there's a situation when it will
eventually return FALSE, I haven't been able to discover it.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Study Abroad Scholarship For Study in Australia...
Next Topic: Biosphere Technology -
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 14 11:16:16 GMT 2024

Total time taken to generate the page: 0.05115 seconds