Home Tutorial Php Examples setcookie()


Share on Google+Share on Google+
Posted on: July 31, 2009 at 12:00 AM
In this example you will learn how to create setcookie() in PHP.


setcookie() sends a HTTP cookie - a small file that the server engrafts on the user's computer - to a client. A cookie must be assigned before any other output is sent to the clients. A name of the cookie is automatically assigned to a variable of the same name. It returns True on success or False on  failure.

setcookie(name, value, expire, path, domain); 

Parameter Description

Name is essential for specifying the cookie; Value is also important while 'cookie expire' is optional, if it is specified, the session expires at the defined time.


# setcookie(name, value, expire, path, domain); // is a function for set cookie but path and domain are optional
setcookie("cookie", "brijesh kumar singh", time()+3600);


Related Tags for setcookie():

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 31, 2009

Recommend the tutorial

Advertisements Advertisements