JavaScriptÖÐCookieµÄ¼òµ¥Ê¹ÓÃ

µ¼Óï ͨ³£Çé¿öÏ£¬ÍøÕ¾Éè¼ÆÕßÊǽèÖúºǫ́Êý¾Ý¿âÀ´ÊµÏÖÒÔÉÏÄ¿µÄµÄ¡£µ±Óû§µÚÒ»´Î·ÃÎʸÃÍøվʱ£¬ÍøÕ¾ÔÚÊý¾Ý¿âÖн¨Á¢Ò»¸öеÄID£¬²¢°ÑIDͨ¹ýCookie´«Ë͸øÓû§¡£Óû§ÔÙ´ÎÀ´·Ãʱ£¬ÍøÕ¾°Ñ¸ÃÓû§ID¶ÔÓ¦µÄ¼ÆÊýÆ÷¼Ó1£¬µÃµ½Óû§µÄ

ͨ³£Çé¿öÏ£¬ÍøÕ¾Éè¼ÆÕßÊǽèÖúºǫ́Êý¾Ý¿âÀ´ÊµÏÖÒÔÉÏÄ¿µÄµÄ¡£µ±Óû§µÚÒ»´Î·ÃÎʸÃÍøվʱ£¬ÍøÕ¾ÔÚÊý¾Ý¿âÖн¨Á¢Ò»¸öеÄID£¬²¢°ÑIDͨ¹ýCookie´«Ë͸øÓû§¡£Óû§ÔÙ´ÎÀ´·Ãʱ£¬ÍøÕ¾°Ñ¸ÃÓû§ID¶ÔÓ¦µÄ¼ÆÊýÆ÷¼Ó1£¬µÃµ½Óû§µÄÀ´·Ã´ÎÊý»òÅжÏÓû§ÊÇÐÂÓû§»¹ÊÇÀÏÓû§¡£

·þÎñÆ÷¿ÉÒÔÀûÓÃCookies°üº¬ÐÅÏ¢µÄÈÎÒâÐÔÀ´É¸Ñ¡²¢¾­³£ÐÔά»¤ÕâЩÐÅÏ¢£¬ÒÔÅжÏÔÚHTTP´«ÊäÖеÄ״̬¡£Cookies×îµäÐ͵ÄÓ¦ÓÃÊÇÅж¨×¢²áÓû§ÊÇ·ñÒѾ­µÇ¼ÍøÕ¾£¬Óû§¿ÉÄÜ»áµÃµ½Ìáʾ£¬ÊÇ·ñÔÚÏÂÒ»´Î½øÈë´ËÍøվʱ±£ÁôÓû§ÐÅÏ¢ÒÔ±ã¼ò»¯µÇ¼ÊÖÐø£¬ÕâЩ¶¼ÊÇCookiesµÄ¹¦Óá£ÁíÒ»¸öÖØÒªÓ¦Óó¡ºÏÊÇ“¹ºÎï³µ”Ö®Àà´¦Àí¡£Óû§¿ÉÄÜ»áÔÚÒ»¶Îʱ¼äÄÚÔÚͬһ¼ÒÍøÕ¾µÄ²»Í¬Ò³ÃæÖÐÑ¡Ôñ²»Í¬µÄÉÌÆ·£¬ÕâЩÐÅÏ¢¶¼»áдÈëCookies£¬ÒÔ±ãÔÚ×îºó¸¶¿îʱÌáÈ¡ÐÅÏ¢,

  1. //´´½¨Ò»¸öCookie 
  2. function createCookie(userName,password){ 
  3.   
  4.     var date=new Date(); 
  5.     date.setTime(date.getTime()+60*1000*60*24);  //±£´æÒ»Ììʱ¼ä 
  6.     document.cookie="userName="+escape(userName)+";expires="+date.toUTCString(); 
  7. //escapeº¯Êý°ÑString×÷Á˱àÂë,setTime¾ÍÊÇCookieµÄ´æ»îÆÚ 
  8.     document.cookie="password="+escape(password)+";expires="+date.toUTCString(); 
  9.     alert(document.cookie); 
  10. //»ñµÃCookieÊý¾Ý 
  11. function getCookie(value){ 
  12.      var cookieString = document.cookie; 
  13.         var start = cookieString.indexOf(value+"=");   //ÕÒ³övalueµÄλÖà
  14.         if(start==-1) 
  15.             return null
  16.         start+=value.length+1;                          //valueµÄ³¤¶È+1,Ò²¾ÍÊÇ=ºóÃæµÄλÖà
  17.         var end=cookieString.indexOf(";",start);       //valuerµÄ³¤¶È+1ÕÒ;µÄλÖà
  18.         if(end==-1)                                    //Ò²¾ÍÊÇ˵£¬Ö»ÓÐÒ»¸öCookieËùÒÔûÓÐ; 
  19.             return cookieString.substring(start); 
  20.          return cookieString.substring(start, end); 
  21.   
  22. //ɾ³ýCookie 
  23. function delCookie(){ 
  24.   
  25.     var date=new Date(); 
  26.     var user=getCookie("userName"); 
  27.     var pwd=getCookie("password"); 
  28.     date.setTime(date.getTime()-1); 
  29. //°Ñµ±Ç°Ê±¼ä-1ºÁÃë,ÓëÏÖÔÚϵͳµÄʱ¼äÒ»¼õ,³ÉÁ˸ºÖµ,ÄÇôÕâ¸öCookie´æ·ÅÔÚϵͳÀï¾Í¹ýÆÚ,¾Í»á±»Ïú»Ù 
  30.     document.cookie="userName="+escape(user)+";"+"expires="+date.toUTCString(); 
  31.     document.cookie="password="+escape(pwd)+";"+"expires="+date.toUTCString(); 

   
 
phpÈçºÎ»ñÈ¡Cookies
 

http://www.aseoe.com/ true JavaScriptÖÐCookieµÄ¼òµ¥Ê¹Óà http://www.aseoe.com/show-12-332-1.html report <£¿php echo strlen($content) / 2; ?> ͨ³£Çé¿öÏ£¬ÍøÕ¾Éè¼ÆÕßÊǽèÖúºǫ́Êý¾Ý¿âÀ´ÊµÏÖÒÔÉÏÄ¿µÄµÄ¡£µ±Óû§µÚÒ»´Î·ÃÎʸÃÍøվʱ£¬ÍøÕ¾ÔÚÊý¾Ý¿âÖн¨Á¢Ò»¸öеÄID£¬²¢°ÑIDͨ¹ýCookie´«Ë͸øÓû§¡£Óû§ÔÙ´ÎÀ´·Ãʱ£¬ÍøÕ¾°Ñ¸ÃÓû§ID¶ÔÓ¦µÄ¼ÆÊýÆ÷¼Ó1£¬µÃµ½Óû§µÄ
±¾Õ¾»¶Ó­ÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-332-1.html

[Ç°¶Ë²å¼þÍƼö] Plugin

1 2 3 4
  • jQueryʵÏÖÖð×ÖÖð¾äÏÔʾ²å¼þl-by-l.min.js
  • jQuery´ø·½Ïò¸ÐÖªµÄÊó±ê»¬¹ýͼƬ±ß¿òÌØЧ²å¼þ
  • jQuery HotKeys¼àÌý¼üÅÌ°´ÏÂʼþkeydown²å¼þ
  • ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
webÇ°¶Ë¿ª·¢
°®Ë¼×ÊÔ´Íø Copyright 2012-2014 Www.Aseoe.Com All rights reserved.(½úICP±¸13001436ºÅ-1)