Jump to content

[SOLVED] Do Sessions require Cookies be turned on?


hanlonj

Recommended Posts

In the case of a session, the cookie only holds an identification number, and when the user who has the cookie accesses the pages that are in the session, their browser identifies itself to the server as holding the session cookie. When the server then sends the page to the user, it uses data that was stored in the $_SESSION array. The beauty of using sessions is that an array value may be stored, and even if the back button is pressed on the browser, the array value is still the same. For this reason a shopping cart is usually set up with a session. The cart itself normally contains items, and when items are added or deleted from the cart, the $_SESSION array is updated. If a user then hits the back button, or browses the site and comes back, the shopping cart is still "alive" and holds the items that are still supposed to be there. I hope this makes sense. There are other reasons for using sessions, and perhaps others might add some knowledge here.

A lot of places use cookies to identify if a person has voted in a poll.  example after a person voted you put a cookie on there computer saying that they voted, this way instead of showing the voting option you show the results...  You may also just want some data that you don't need to keep perminitly but just helps to make your site look better and instead of storing it in a database, you give them a cookie if they delete it doesn't matter, just like things such as user last visited this post at 12:oo pm, there was a new post at 3:00pm so put a little image saying new post next to the link, if there was no new post after 12:00pm no action.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.