ͨ³£Çé¿öÏ£¬ÍøÕ¾Éè¼ÆÕßÊǽèÖúºǫ́Êý¾Ý¿âÀ´ÊµÏÖÒÔÉÏÄ¿µÄµÄ¡£µ±Óû§µÚÒ»´Î·ÃÎʸÃÍøվʱ£¬ÍøÕ¾ÔÚÊý¾Ý¿âÖн¨Á¢Ò»¸öеÄID£¬²¢°ÑIDͨ¹ýCookie´«Ë͸øÓû§¡£Óû§ÔÙ´ÎÀ´·Ãʱ£¬ÍøÕ¾°Ñ¸ÃÓû§ID¶ÔÓ¦µÄ¼ÆÊýÆ÷¼Ó1£¬µÃµ½Óû§µÄÀ´·Ã´ÎÊý»òÅжÏÓû§ÊÇÐÂÓû§»¹ÊÇÀÏÓû§¡£
·þÎñÆ÷¿ÉÒÔÀûÓÃCookies°üº¬ÐÅÏ¢µÄÈÎÒâÐÔÀ´É¸Ñ¡²¢¾³£ÐÔά»¤ÕâЩÐÅÏ¢£¬ÒÔÅжÏÔÚHTTP´«ÊäÖеÄ״̬¡£Cookies×îµäÐ͵ÄÓ¦ÓÃÊÇÅж¨×¢²áÓû§ÊÇ·ñÒѾµÇ¼ÍøÕ¾£¬Óû§¿ÉÄÜ»áµÃµ½Ìáʾ£¬ÊÇ·ñÔÚÏÂÒ»´Î½øÈë´ËÍøվʱ±£ÁôÓû§ÐÅÏ¢ÒÔ±ã¼ò»¯µÇ¼ÊÖÐø£¬ÕâЩ¶¼ÊÇCookiesµÄ¹¦Óá£ÁíÒ»¸öÖØÒªÓ¦Óó¡ºÏÊÇ“¹ºÎï³µ”Ö®Àà´¦Àí¡£Óû§¿ÉÄÜ»áÔÚÒ»¶Îʱ¼äÄÚÔÚͬһ¼ÒÍøÕ¾µÄ²»Í¬Ò³ÃæÖÐÑ¡Ôñ²»Í¬µÄÉÌÆ·£¬ÕâЩÐÅÏ¢¶¼»áдÈëCookies£¬ÒÔ±ãÔÚ×îºó¸¶¿îʱÌáÈ¡ÐÅÏ¢,
- //´´½¨Ò»¸öCookie
- function createCookie(userName,password){
- var date=new Date();
- date.setTime(date.getTime()+60*1000*60*24); //±£´æÒ»Ììʱ¼ä
- document.cookie="userName="+escape(userName)+";expires="+date.toUTCString();
- //escapeº¯Êý°ÑString×÷Á˱àÂë,setTime¾ÍÊÇCookieµÄ´æ»îÆÚ
- document.cookie="password="+escape(password)+";expires="+date.toUTCString();
- alert(document.cookie);
- }
- //»ñµÃCookieÊý¾Ý
- function getCookie(value){
- var cookieString = document.cookie;
- var start = cookieString.indexOf(value+"="); //ÕÒ³övalueµÄλÖÃ
- if(start==-1)
- return null;
- start+=value.length+1; //valueµÄ³¤¶È+1,Ò²¾ÍÊÇ=ºóÃæµÄλÖÃ
- var end=cookieString.indexOf(";",start); //valuerµÄ³¤¶È+1ÕÒ;µÄλÖÃ
- if(end==-1) //Ò²¾ÍÊÇ˵£¬Ö»ÓÐÒ»¸öCookieËùÒÔûÓÐ;
- return cookieString.substring(start);
- return cookieString.substring(start, end);
- }
- //ɾ³ýCookie
- function delCookie(){
- var date=new Date();
- var user=getCookie("userName");
- var pwd=getCookie("password");
- date.setTime(date.getTime()-1);
- //°Ñµ±Ç°Ê±¼ä-1ºÁÃë,ÓëÏÖÔÚϵͳµÄʱ¼äÒ»¼õ,³ÉÁ˸ºÖµ,ÄÇôÕâ¸öCookie´æ·ÅÔÚϵͳÀï¾Í¹ýÆÚ,¾Í»á±»Ïú»Ù
- document.cookie="userName="+escape(user)+";"+"expires="+date.toUTCString();
- document.cookie="password="+escape(pwd)+";"+"expires="+date.toUTCString();
- }
±¾Õ¾»¶ÓÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-332-1.html
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-332-1.html