homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

How to check if a Session has been started
with $_SESSION variable

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

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


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)

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



 8:24 pm on Sep 4, 2002 (gmt 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 Sep 4, 2002 (gmt 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...



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

Thanks Nick_W

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved