Download
    Interview Question     &Answer
Main Menu
PHP Cookies@ Shwetank education.com
  PHP Cookie
Cookies are little files that are stored on a user's computer by the server. They are usually used to identify a user. When you browse to a site that has stored a cookie again, your web browser also sends the cookie.


Syntax
<?php
setcookie($name, $value, $expire, )
?>
$name - name of the cookie. Example: "username"
$value - value of the cookie. Example: "Shwetank Kumar gupta"
$expire - time (in UNIX timestamp) when the cookie will expire. Example: time()+"3600".
Cookie is set to expire after one hour.

Cookies Example
<?php
setcookie("username", "Shwetank Kumar Gupta", time()+3600);
?>
Note*- Cookie is set to expire after one hour.
Set Cookie 1 year
<?php
setcookie("username", "Herry", time()+(60*60*24*365));
?>

Retrieving a cookie
Cookie information can retrieved using the predefined $_COOKIE array.
The following will retrieve our username cookie value
<?
php echo $_COOKIE["username"];
?>

Deleting a Cookie:
<?php
setcookie("username", "john", time()-(60*60*24*365));
?>

IT  Projects Links
M-Tech Thesis
Php Project
Java Project
Asp.Net Project
Android Project
Vb .Net Project
Html Project

------------------------------- Electronics  Project
Networking
Embedded system
Telecom
Robotics
CCNA
------------------------------- Latest IT  News


Copyright 2010-2015    shwetankeducation.com
Privacy & Terms