Continue session without outputting cookie?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Jace
Forum Newbie
Posts: 12
Joined: Fri Jan 15, 2010 5:33 pm

Continue session without outputting cookie?

Post by Jace »

Normally to start or continue a session I use session_start. This reads the Session ID from a cookie, and continues the session if it existed, or creates a new one and outputs the newly created Session ID as a cookie.

However, is it also possible to only read the ID from the cookie, and (if present) continue the session, but otherwise don't create / start a new session? I.e. some kind of session_continue() function, which does not output any headers?

(Oh and I certainly don't want any Session IDs on the URL. In this case need just to read the cookie and continue, or no session at all.)
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Continue session without outputting cookie?

Post by Darhazer »

Somethink like:

Code: Select all

 
if (isset($_COOKIE[session_name()])) {
    session_id($_COOKIE[session_name()]);
    session_start();
}
 
Post Reply