Home > Backend Development > PHP Tutorial > General assignment method to delete cookies in php_PHP tutorial

General assignment method to delete cookies in php_PHP tutorial

WBOY
Release: 2016-07-21 15:29:24
Original
795 people have browsed it

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).

www.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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template