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

  • 相关阅读:
    3.Java入门程序,在dos下运行Hello World
    2.javase环境的搭建
    1.Java语言的简介
    常见的dos命令
    计算机基础
    网络工程师-个人笔记三
    网络工程个人笔记二
    网络工程师个人笔记一
    Vuex
    cookie session sessionStorage localStorage
  • 原文地址:https://www.cnblogs.com/cyany/p/10011974.html
Copyright © 2020-2023  润新知