Forum Moderators: coopster

Message Too Old, No Replies

PHP Sessions or Cookies

Which is the best tot use

         

Red_Eye

12:16 pm on Jan 5, 2004 (gmt 0)

10+ Year Member



I am looking at creating a simple user login screen using php and mysql, I would like to know which would be better to use PHP sessions or cookies.

JasonD

1:03 pm on Jan 5, 2004 (gmt 0)

10+ Year Member



It's definately easier to use sessions though the definition of "easiness"in this instance needs clarification.

Do you mean easier to code?
Easier for the end user?
Easier for search engines to parse?
Easier for some other reason?

Red_Eye

4:19 pm on Jan 5, 2004 (gmt 0)

10+ Year Member



The bottom 3 conditions apply the top one is minor.

ergophobe

4:28 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm sure you know this, but FWIW, keep in mind that by default, sessions will try to use cookies to store the session ID. You can force it not to do so or allow it not to do so if cookies are disabled, but normally it will write a cookie.

coopster

4:29 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think it will come down to the level of security required. If you need little or no security, then a simple cookie technique would work. If you want it secure, then I would definetly use sessions with cookies. There is a decent PDF titled Session Fixation [php.net] on the PHP Session handling page that can clarify things a bit for you.