PHP cookies deletion, assignment method_PHP tutorial

WBOY
Release: 2016-07-13 16:59:03
Original
956 people have browsed it

php tutorial cookies deletion, assignment method

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. With php you can create and retrieve cookie values ​​

Grammar

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.bKjia.c0m', $e = 0,$isdes=1);


For more details, please check: http://www.bKjia.c0m/phper/php/34040.htm

More detailed methods

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 placed 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/631339.htmlTechArticlephp tutorial cookies deletion, assignment method 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