Forum Moderators: coopster

Message Too Old, No Replies

Session ID's AND cookies

possible?

         

drewst

3:18 pm on May 10, 2005 (gmt 0)

10+ Year Member



Is it possible to use session ID's and cookies together or is it one or the other?

basically i want esablish a session when a user is on my site, once they go i want the session to be deleted (as it is doing)

However when the user returns i want to check for a cookie to see if they are returning.

I dont really wnat to use a timestamp approach in the session ID and check against this when a visitor returns.

so can i use them together?
Thanks
Drew

kazecoder

3:48 pm on May 10, 2005 (gmt 0)

10+ Year Member



I wouldnt see why you couldnt. Just have php create the cookie before the session is ended. Then have it check again when the session starts.

Stormfx

4:51 pm on May 10, 2005 (gmt 0)

10+ Year Member



By default, PHP tries to write a session cookie that stores the session id. However, the cookies expire time isn't that high.

You can create a new cookie and assign it the session id and then set the time to an acceptable amount.

mcibor

9:37 pm on May 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no problem in using session and cookies together. Just remember, that in PHP cookies must be sent before any headers. There's a way of setting a cookie after page is loaded, but it uses javascript. So just start the session, set the cookie if it's not set already and voile!

Best regards
Michal Cibor

drewst

9:49 pm on May 10, 2005 (gmt 0)

10+ Year Member



thanks guys,

Yeh got it sorted now, i was doing the silly thing of trying to drop a cookied before starting a session, bit or rearranging and its working great

Thanks
Drew