Cookies Explained

Your rating: None Average: 4.5 (2 votes)

Cookies are actually just an extension of the HTTP protocol. Specifically, there are two additional HTTP headers: Set-Cookie and Cookie. The operation of these cookies is best described by the following series of events:
1. Client sends an HTTP request to server.
2. Server sends an HTTP response with Set-Cookie: foo=bar to client.
3. Client sends an HTTP request with Cookie: foo=bar to server.
4. Server sends an HTTP response to client.

Thus, the typical scenario involves two complete HTTP transactions. In step 2, the server is asking the client to return a particular cookie in future requests. In step 3, if the user’s preferences are set to allow cookies, and if the cookie is valid for this particular request, the browser requests the resource again but includes the cookie.

The Set-Cookie header, at a minimum, contains the name and value of the cookie.

For example,
Set-Cookie: foo=bar

Other attributes can be included to modify when the cookie is to be sent in a subsequent request.These optional attributes are as follows:

domain—Restricts requests for which the cookie is sent to those that are within the specified domain or in subdomains.
The default is the domain of the current resource.

expires—A date after which the cookie is no longer valid and should be deleted.
The default is to persist the cookie in memory only, expiring it as soon as the browser ends.

path—Only requests for resources within the specified path include the cookie.
The default is no path restrictions.

secure—An attribute with no value that indicates that the cookie should only be sent in requests sent over a secure connection, such as SSL.

In PHP, cookies sent in the request are made available in the $_COOKIE superglobal array.

 #

its nice..
keep it

 
 #

Thank's for your comments

 

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

I love work environment which is:

Informal yet professional
Demanding yet rewarding
Challenging yet inspiring
Mediocrity is not an option
Having fun is serious business
Making mistakes is human
Forgiveness is Company Policy

Travelling Sucks