Welcome to WebmasterWorld Guest from 54.167.213.22

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to check if a Session has been started

with $_SESSION variable

     
7:45 pm on Sep 4, 2002 (gmt 0)

10+ Year Member



Hi all,
How can I go about checking to see if a session has been started?

session_start();
$this->resetMessages();

I want it to check if session has started, if it has not, then execute the code above. But I'm not sure on how to tell it to check with $_SESSION variable.

Thanks for the help.

7:55 pm on Sep 4, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



maybe you could use session_is_registered() [php.net] to check if a session var is registered and base your logic on that?

Nick

8:24 pm on Sep 4, 2002 (gmt 0)

10+ Year Member



I should have posted this earlier.

The error I keep getting is
Warning: Cannot send session cache limiter - headers already sent (output started at /common/browser.detector.php:134) in /common/user.auth.php on line 13

And I'm not sure why it's doing it. From what I've been reading on php.net (http://www.php.net/manual/en/function.session-start.php),
session_start looks for an existing session, if it doesn't find one,
then it creates a new session.

So I'm not sure why I keep getting this error?

Thanks once again

8:30 pm on Sep 4, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You can't use sessions or cookies after you have already sent content to the browser.

Do your session stuff before you send any html or white space...

Nick

9:52 pm on Sep 4, 2002 (gmt 0)

10+ Year Member



Thanks Nick_W

That was the problem. I really appreciate the help :)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month