การใช้ฟังก์ชั่น เกี่ยวกับ Cookie
setcookie(string name [,string value [,int expire [,string path
[,string domain [,int secure]]]]]);
$_COOKIE["string name"];
$HTTP_COOKIE_VARS["string name"];
Ex.1
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1);
?>
<?php
// Print an individual cookie
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
// Another way to debug/test is to view all cookies
print_r($_COOKIE);
?>
Ex.2
<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1);
?>
ที่มา:=> www.php.net |
|
สร้างเมื่อวันที่ : 15-07-2548