Forum Moderators: coopster

Message Too Old, No Replies

quick question on cookies

         

bobnew32

9:08 pm on Oct 24, 2003 (gmt 0)

10+ Year Member



I now know how to ultilize cookies and session data, but is there a check I can in the code that sees if sessions/cookies are available?

I'd be doing somthing like this if you cared to know (i'm just throwing this out, i'm not asking somone to fill in the blanks, only the if statment to see if cookies are available.


if(cookies are available)
{
do session junk
}

if(cookies are not available)
{
append session id
}

Timotheos

9:30 pm on Oct 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's an example of this in user comments [php.net] of the manual.

BTW, it's my understanding that you can have PHP do this automatically if your settings are right.

session.use_cookies boolean
session.use_cookies specifies whether the module will use cookies to store the session id on the client side. Defaults to 1 (enabled).

session.use_only_cookies boolean
session.use_only_cookies specifies whether the module will only use cookies to store the session id on the client side. Defaults to 0 (disabled, for backward compatibility). Enabling this setting prevents attacks involved passing session ids in URLs. This setting was added in PHP 4.3.0.

So by default if it can't set a cookie then it will append it in the URL. Just have to be aware of the possibility of session hijacking.