Header menu

_________________________________________________________________________________
Showing posts with label Explain Cookie. Show all posts
Showing posts with label Explain Cookie. Show all posts

Friday, 24 January 2014

Set a cookie / Use a cookie / Discuss a cookie / Explain Cookie


How to set a cookie.

Use setcookie() for setting a cookie.

Example : setcookie('flavor','vanilla');

Calling setcookie()

Cookies are sent with the HTTP headers, so setcookie() must be called before any output is generated. 

Use a Cookie

<?php
// Print an individual cookie
echo $_COOKIE["flavor"]; ?>
 


Arguments to setcookie()

You can pass additional arguments to setcookie() to control cookie behavior. The third argument to setcookie() is an expiration time,expressed as an epoch time- stamp.

Example setcookie('flavor','vanilla',1202075201);