Welcome to WebmasterWorld Guest from 23.22.140.143

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)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 0


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 Sept 4, 2002 (gmt 0)

Senior Member

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

joined:Feb 4, 2002
posts:5044
votes: 0


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 Sept 4, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 0


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 Sept 4, 2002 (gmt 0)

Senior Member

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

joined:Feb 4, 2002
posts:5044
votes: 0


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 Sept 4, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 0


Thanks Nick_W

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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members