General assignment methods deleted in php cookies Cookies are often used to identify users. Cookies are small files that a server leaves on a user's computer. Whenever the same computer requests a page through the browser, it also sends the cookie. Through php, you can create and retrieve cookie values
Syntax
Copy code The code is as follows:
setcookie( name, value, expire, path, domain);
**
* Set cookie
* n Name
* c Value
* e Validity period 0 Default is one month 1 Close and expire immediately
*/
function w_cookie($n, $c, $e = 0,$isdes=1)
{
if($isdes==1){$c=endes($ c,deskey);}
$exp = time() + 3600 * 24 * 30;
if($e == 0)
{
setcookie($n, $c, $exp ,"/");
}
else
{
setcookie($n, $c,0,"/");
}
}
//Close cookie method
w_cookie('bb', 'www.3ppt.com', $e = 0,$isdes=1);
function set_cronology($name,$ value,$duration=7){
$duration=time()+(3600*24*$duration);
$max_stored_values=5;
if(isset($_cookie[$name])) {
foreach($_cookie[$name] as $prop_crono=>$val_crono){
if($val_crono==$value)
return;
}
if($prop_crono< ;$max_stored_values)
setcookie($name.'['.($prop_crono+1).']',$value,$duration);
else{
array_shift($_cookie[$name] );
setcookie("$name[$max_stored_values]",$value,$duration);
}
}else
setcookie($name.'[0]',$value,$ duration);
return;
}
?>
Note: The setcookie() function must be located before the tag. The cookie value is automatically url-encoded when sending the cookie and automatically decoded when retrieved (to prevent url-encoding, use setrawcookie() instead).
http://www.bkjia.com/PHPjc/323387.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323387.htmlTechArticleGeneral assignment method deleted in php cookies Cookies are often used to identify users. Cookies are small files that a server leaves on a user's computer. Whenever the same computer requests a page via a browser...