Post a Reply
|Oldest Newest Rating|
· October 9, 2014
Session is like a variable that will work until the user close the browser.
Cookie is like a variable that will work for limit of the time you set. (ie: 1year, 30months, and so on)
Obviously, this is not a good definition. But this is how I see those as..
Also, check out the PHP manual. I think they explain more and better than me.
· October 12, 2014
I don't know about an excellent concept, but here is what I have learned over the last couple years:
Both are used to store data for the web page. Think of a cookie as client side storage, and a session as server side storage.
A cookie will store information on the users computer and an expiration date is set for when that information is removed. This information can be recalled at a later time and date as long as the user visits within the expiration time and with the same computer/browser.
A session is stored on the server side and can be used to store more sensitive information. Only the session ID is stored on the client side, all other info is on the server side. The ID is destroyed when the user closes their browser.
Sessions are typically used for controlling log in information, but they can also be used for shopping carts, etc. One of the things I use them for is storing browser information at times. When someone visits a page with an older browser (ie 6, 7 etc.), I give them an alert notice that their browser is not supported by my site, then store a session variable stating that I have given this notice so that I don't continue to give the same alert every time that the user refreshes the page, or visits another page on the site.