zoukankan      html  css  js  c++  java
  • php cookie

    setcookie(name,value,expire_time,path,domain,security);
    
    name name
    value value
    Expiry − This specify a future time in seconds since 00:00:00 GMT on 1st Jan 1970. After this time cookie will become inaccessible. If this parameter is not set then cookie will automatically expire when the Web Browser is closed.
    
    Path − This specifies the directories for which the cookie is valid. A single forward slash character permits the cookie to be valid for all directories.
    
    Domain − This can be used to specify the domain name in very large domains and must contain at least two periods to be valid. All cookies are only valid for the host and domain which created them.
    
    Security − This can be set to 1 to specify that the cookie should only be sent by secure transmission using HTTPS otherwise set to 0 which mean cookie can be sent by regular HTTP.
    
    

    Example:

    setcookie("name","cyany_blue");
    sleep(1);
    echo $_COOKIE["name"]."<br>";
    echo time()."<br>";
    setcookie("blue123","color123",time()+36000000,"/","","0");
    if(isset($_COOKIE["name"])){
    	echo $_COOKIE["name"];
    }else{
    	echo "not found!";
    }
    // if you want to delete cookie ,you can set exprie_time to pass time .
    setcookie("name","456",time()-3600,"/","",0);
    echo $_COOKIE["name"];
    

  • 相关阅读:
    1034: [ZJOI2008]泡泡堂BNB
    1084: [SCOI2005]最大子矩阵
    1046: [HAOI2007]上升序列
    LIS最长上升子序列模板
    1070: [SCOI2007]修车
    1057: [ZJOI2007]棋盘制作
    1066: [SCOI2007]蜥蜴
    1059: [ZJOI2007]矩阵游戏
    1050: [HAOI2006]旅行comf
    1083: [SCOI2005]繁忙的都市
  • 原文地址:https://www.cnblogs.com/cyany/p/10011974.html
Copyright © 2011-2022 走看看