Thanks for your help! Zend_Session::isStarted() seems to do the trick.
Its a bit unfortunate though that it does not appear in the Reference Guide.
And although I understand the logic behind sessionExists(), I think lots of
other developers might make the same mistake of expecting sessionExists() to
work straight away from the first request.
Cheers,
Antonio
Pádraic Brady wrote:
>
> Not necessarily. Try replacing with a call to isStarted() for example.
>
> You can have a session started, but not immediately existing (i.e.
> detected) for the current page. It is normal to require at least one
> additional request for a session existence check to be detectable.
>
> You have to bear in mind what existence means - that the client has a
> cookie or has passed an SID via other means. Obviously the current page
> setting those values, needs another request so the browser can notify it
> if these are set via $_COOKIE or $_REQUEST (GET|POST).
>
> Paddy
>
>
> JARUZ wrote:
>>
>> Sample code:
>>
>> Zend_Session::start();
>> if( Zend_Session::sessionExists() ) {
>> echo 'Session exists';
>> }
>> else {
>> echo 'Session does not exist';
>> }
>>
>> Will output "Session does not exist" for the FIRST request to the page.
>> Subsequent calls to the page work fine.
>>
>> Clearly since the session was started, sessionExists() should return true
>> even the first time. Right?
>>
>> Cheers,
>>
>>
>> Antonio
>>
>
>
--
View this message in context:
http://www.nabble.com/Possible-bug-with-sessionExists%28%29---tp17405075p17412249.html
Sent from the Zend Framework mailing list archive at Nabble.com.