1ï¼ dateaddæ³
1)å°æé设置为å½åæ¥æåç第N天ç0æ¶0å0ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âdâ,N,date)
2)å°æé设置为å½åæ¥æåç第Næçåä¸å¤©ç0æ¶0å0ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âmâ,N,date)
3)å°æé设置å°å½åæ¶é´åç第N天ç该æ¶è¯¥å该ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âdâ,N,now)
4)å°æé设置å°å½åæ¶é´åç第N+M天ç该æ¶è¯¥å该ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âdâ,N,now+M)
5)å°æé设置å°å½åæ¶é´åç第Næç该æ¶è¯¥å该ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âmâ,N,now)
6)å°æé设置å°å½åæ¶é´åç第Næçåä¸æ¥åç第M天ç该æ¶è¯¥å该ç§
Response.Cookies(âLastViewâ).Expires=dateadd(âmâ,N,now+M)
2ï¼ ç¡®å®æ¥ææ³
1ï¼å°æé设置å°æä¸æ¥ç0æ¶0å0ç§å¤±æ
举ä¾ï¼å°2003å¹´1æ29æ¥0æ¶0å0ç§å¤±æ
Response.Cookies(âLastViewâ).Expires=# 1/29/2003 #
æ
Response.Cookies(âLastViewâ).Expires=# 2003/1/29 #
æ
Response.Cookies(âLastViewâ).Expires=âJanuary 29,2003â
2)å°æé设置å°æä¸æ¥çæä¸æ¶å»å¤±æ
举ä¾ï¼å°2003å¹´1æ29æ¥21æ¶0å0ç§å¤±æ
Response.Cookies(âLastViewâ).Expires = #2003/1/29 21:00:00#
æ
Response.Cookies(âLastViewâ).Expires = #1/29/2003 21:00:00#
æ
Response.Cookies(âLastViewâ).Expires = #January 29,2003 21:00:00#
å
¶å®ï¼å¨è¿ç§æ¹æ³ä¸ï¼ç¨ââ ââåâ# #âçæææ¯ä¸æ ·çãä¾å¦
Response.Cookies(âLastViewâ).Expires=âJanuary 29,2003â
å
Response.Cookies(âLastViewâ).Expires=# January 29,2003 # çææå°±æ¯ç¸åçã
3ï¼ date+ \now+ æ³
è¿ç§æ¹æ³ä¸»è¦ç»æ为Date+æ°å¦å¼ænow +æ°å¦å¼ãéè¿ç®åçååè¿ç®çæ¹æ³ï¼å°Cookie ç失ææ¶é´è®¾ç½®å°å½åæ¶é´åçæä¸æ®µæ¶é´å
ãè¿éçå å·é½è¡¨ç¤ºå¨å½åæ¶é´çåºç¡ä¸å ä¸é¢è®¾æ¶é´ã
1)date+æ³
å¦å°æé设置为å½åæ¥æåç第N天ç0æ¶0å0ç§ï¼æ们å¯ä»¥ä½¿ç¨ä¸è¿°å·²è°å°è¿çæ¹æ³ä¹å¯ä»¥ä½¿ç¨å¦ä¸æ ¼å¼ï¼
Response.Cookies(âLastViewâ).Expires=Date+N
date+æ³æ¯ä¸ç§æ¯è¾æ»çæ¹æ³ãå®åä¸è¿°æ¹æ³å·®å«ä¸æ¯å¾å¤§ï¼å®å
¨å¯ä»¥ç±ä¸è¿°å ç§æ¹æ³ä»£æ¿ãä¸é¢ä»ç»now+æ³ï¼è¿æ¯ä¸ç§æ¯è¾çµæ´»çæ¹æ³ï¼å®å¯ä»¥å°å¤±ææ¶é´åç¡®å°å®ä½å°å½åæ¶é´åçä»»æä¸å¹´ãä¸æãä¸å¤©ãä¸å°æ¶ãä¸åãä¸ç§ã
2)now+æ³
å
举ä¸ä¸ªä¾åï¼ Response.Cookies(âLastViewâ).Expires = now+1
è¿æ¡è¯å¥çåè½æ¯ï¼æCookieç失ææ¶é´éå¶å°1天åçåä¸æ¶å»ãè¿éç1代表1天ï¼å³24å°æ¶ãç±äºnow代表å½åWebæå¡å¨çç³»ç»æ¶é´ï¼å
æ¬å¹´ãæãæ¥ãæ¶ãåãç§ï¼å该è¯å¥æ表达å¾Cookie ç失ææ¥æå¨æ天çåä¸æ¶ãåãç§ä¸ãè¥æ¹ænow+2å表示æ¤Cookie ç失ææ¥æå¨ä¸¤å¤©åçåä¸æ¶ãåãç§ä¸ï¼now+30表示æ¤Cookie ç失ææ¥æå¨ä¸ä¸ªæåçåä¸æ¶ãåãç§ä¸ï¼now+30*2表示æ¤Cookie ç失ææ¥æå¨ä¸¤ä¸ªæåçåä¸æ¶ãåãç§ä¸ï¼now+365å表示æ¤Cookie ç失ææ¥æå¨ä¸å¹´åçåä¸æ¶ãåãç§ä¸â¦â¦
å½æ1åæ24ç份ï¼å³è¯¥è¯å¥åæï¼ Response.Cookies(âLastViewâ).Expires = now+1/24å表示æCookieç失ææ¶é´éå¶å°ä¸å°æ¶åãå¨æ¤åºç¡ä¸ï¼æ1åå60ç份ï¼å³ænow+1/24æ¹æ now+1/1440ï¼å表示æCookieç失ææ¶é´éå¶å°ä¸åéåãè¿éç1440æ¯ç±24*60å¾æ¥ãåçï¼è¦æCookieç失ææ¶é´éå¶å°ååéåï¼åæç¨åºåæResponse.Cookies(âLastViewâ).Expires = now+10/1440ï¼è¦æCookieç失ææ¶é´éå¶å°ä¸ç§éåï¼åç¨åºåæResponse.Cookies(âLastViewâ).Expires = now+1/86400ãå½ç¶ï¼ç论ä¸æCookieç失ææ¶é´éå¶å°å¾®ç§çº§ä¹æ¯å¯ä»¥çãä¸è¿ï¼é£å°±æ²¡æä»ä¹å®é
æä¹äºãå¦å¤ï¼å¦æç¨åºè¯å¥åæï¼ Response.Cookies(âLastViewâ).Expires = now+1+1/1440å表示Cookieç失ææ¶é´ä¸º24å°æ¶é¶ä¸åéåã
温馨提示:答案为网友推荐,仅供参考