Re: session_is_registered gets session values only after doing some output first !?

From: Date: Wed, 23 Jun 2004 12:00:44 +0000
Subject: Re: session_is_registered gets session values only after doing some output first !?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-188862@lists.php.net to get a copy of this message
Frank Rust wrote:
I try to check if a session is registered. This works fine if I first do some output echo "abc"; if (!session_is_registered('userid')) { do_something(); } else { redirect_to_somewhere(); } and I can't redirect to another page ... If I comment out the echo statement I get always false and $_SESSION is empty, but I could redirect somewhere... I tried php 4.3.1 and 4.3.7 with apache 2.0.45 both the same. On a Windows box the same program runs fine. Can anybody help? _________________________________________________________________________ Frank Rust, Technische Universität, Institut für Theoretische Informatik
Tel.: +49 531 391 9525                Postfach 3329, D-38023 Braunschweig
Fax.: +49 531 391 9529       Mühlenpfordtstr. 22-23, D-38106 Braunschweig
You ought to make sure that the session was already started before trying to work with it. Either start the session implicitly via session.auto_start = 1 in your php.ini so a session is always started automatically or explicitly start it via session_start(). As long as the session is not started the session-array ($_SESSION, HTTP_SESSION_VARS) is not set.

« previous php.general (#188862) next »