Home > php教程 > php手册 > javascript php 添加cookie,删除cookie

javascript php 添加cookie,删除cookie

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:00:51
Original
1332 people have browsed it

php cookie //add cookie $time = time() + 3600 * 24 * 30; setcookie('UserIId', $_GET["userid"], $time); setcookie('UserPwd', $_GET["pwd"], $time); //del cookie $time = time() - 3600; setcookie('UserIId', '', $time); setcookie('UserPwd', '',

 

php cookie

//add cookie

        $time = time() + 3600 * 24 * 30;
        setcookie('UserIId',  $_GET["userid"], $time);
        setcookie('UserPwd', $_GET["pwd"], $time);

//del cookie

        $time = time() - 3600;
        setcookie('UserIId',  '', $time);
        setcookie('UserPwd', '', $time);

//get cookie

$_COOKIE["UserIId"];

javascript

//add cookie
function saveTmpEmail(){
   var Then=new Date();
   var uemailStr=document.getElementById("login_email").value;
   Then.setTime(Then.getTime() +3600*1000*24*300 );
 
     document.cookie='UserIId='+uemailStr+';expires='+ Then.toGMTString();
     document.cookie='UserPwd=55555;expires='+Then.toGMTString();

}
//取cookie
function getCookieData(label){
   var labelLen=label.length;
   var cLen=document.cookie.length;
   var i=0;
   var cEnd;
  while(i   var j=i+labelLen;
    if(document.cookie.substring(i,j)==label){
      cEnd=document.cookie.indexOf(";",j);
      if(cEnd==-1){
        cEnd=document.cookie.length;
      }
      return document.cookie.substring(j+1,cEnd);
    }
    i++
  }
  return ""
}

Related labels:
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template