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"];
    

  • 相关阅读:
    关于linux curl 地址参数的问题
    mac系统安装php redis扩展
    Shell获取上一个月、星期的时间范围
    python redis使用
    python pycurl模块
    Memcached常规应用与分布式部署方案
    mysql忘记密码重置(mac)
    shell命令从目录中循环匹配关键词
    python两个文件的对比
    MySQL优化方案
  • 原文地址:https://www.cnblogs.com/cyany/p/10011974.html
Copyright © 2011-2022 走看看