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

  • 相关阅读:
    Exercice_3.8
    Exercice_3.13.1_练习使用vector2
    Exercice_3.13_练习使用vetor
    Exercice_3.10_去掉string对象中的标点符号
    Exercice_3.7_判断两个字符串的大小和长度
    1-日期时间视图 2-长按事件
    View(视图)2
    View(视图)
    计算器(UI事件)给按钮添加监听器
    Activity(活动)
  • 原文地址:https://www.cnblogs.com/cyany/p/10011974.html
Copyright © 2011-2022 走看看