Session , Cookies , Request .........

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sagarpparakh
Forum Newbie
Posts: 4
Joined: Fri Jan 01, 2010 11:00 pm

Session , Cookies , Request .........

Post by sagarpparakh »

I am slightly confused with this words. As I am working on php dev. i know use of Get and post method but finding difficult to understand the accurate meaning of Session , Cookies and request on php Dev.


Any One Please can you explain this words .... Thanks in Advance ....
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Session , Cookies , Request .........

Post by alex.barylski »

SESSION persist for the duration of the application, once your browser closes (tyypically this can be changed) your session variables are destroyed. They are specific to individual user.

COOKIE persist similar to SESSION (again can be changed) but are stored on the client side as opposed to the server side, like SESSION. Cookies are limited in the amount of data they can persist, so most developers prefer session storage as the limit is far greater.

You would typically use both to store items for a shopping cart, etc which are saved until the user closes browser, checkout, etc.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Session , Cookies , Request .........

Post by Jonah Bron »

And request is just a super-global variable ($_SESSION) that has the contents of $_POST, $_GET, and, I think, $_COOKIE.
sagarpparakh
Forum Newbie
Posts: 4
Joined: Fri Jan 01, 2010 11:00 pm

Re: Session , Cookies , Request .........

Post by sagarpparakh »

Thanks .....
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Session , Cookies , Request .........

Post by flying_circus »

What Jonah said about $_REQUEST, and never use it! It does contain $_GET, $_POST, and $_COOKIE data, in some order. If $_GET, $_POST, or $_COOKIE contain the same-named variable, one will take precedence, and the other will be overwritten.
Post Reply