asp.net cookie
HttpCookie ck = Request.Cookies["cktest"];
2 if (ck == null)
3 {
4 ck = new HttpCookie("cktest");
5 ck.Value = "123";
6
7 ck.Expires = DateTime.Now.AddSeconds(20);//20秒的有效期
8 Response.Cookies.Add(ck);
9 Response.Write("new ck");
10 }
11 else
12 {
13 Response.Write(ck.Value.ToString());
14 }
15
2 if (ck == null)
3 {
4 ck = new HttpCookie("cktest");
5 ck.Value = "123";
6
7 ck.Expires = DateTime.Now.AddSeconds(20);//20秒的有效期
8 Response.Cookies.Add(ck);
9 Response.Write("new ck");
10 }
11 else
12 {
13 Response.Write(ck.Value.ToString());
14 }
15
1、定義Cookie : HttpCookie ck=new HttpCookie("cktest");
2、獲取Cookie : Request.Cookies["cktest"];
3、新增Cookie : Response.Cookies.Add(ck);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-630580/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ASP.NET之CookieASP.NETCookie
- ASP.NET Core Authentication系列(三)Cookie選項ASP.NETCookie
- ASP.NET MVC下使用AngularJs語言(七):Cookie的使用ASP.NETMVCAngularJSCookie
- ASP.NET Core Web Api之JWT VS Session VS Cookie(二)ASP.NETWebAPIJWTSessionCookie
- 理解ASP.NET Core - 基於Cookie的身份認證(Authentication)ASP.NETCookie
- ASP.NET Core之身份驗證和授權Cookie&SessionASP.NETCookieSession
- 新增cookie、刪除cookie、清除cookieCookie
- asp.net core 3.1多種身份驗證方案,cookie和jwt混合認證授權ASP.NETCookieJWT
- Java操作Cookie之新增CookieJavaCookie
- CookieCookie
- ASP.NET Core Authentication系列(四)基於Cookie實現多應用間單點登入(SSO)ASP.NETCookie
- 如何獲取Cookie並使用Cookie侵入Cookie
- 如何設定cookie和刪除cookieCookie
- cookie sessionCookieSession
- 新增cookieCookie
- go cookieGoCookie
- Cookie 起源Cookie
- javascript cookieJavaScriptCookie
- cookie & sessionCookieSession
- Cookie原理Cookie
- cookie外掛-jquery.cookie.js介紹CookiejQueryJS
- Python Cookie HTTP獲取cookie並處理PythonCookieHTTP
- Python Flask,cookie,設定、獲取、刪除cookiePythonFlaskCookie
- cookie跨域共享 cookie二級域名共享 前後端分離專案共享cookieCookie跨域後端
- Cookie小記Cookie
- Cookie學習Cookie
- iOS - WKWebView CookieiOSWebViewCookie
- Cookie筆記Cookie筆記
- cookie 和 sessionCookieSession
- cookie、sessionStorage、localStorageCookieSession
- Cookie Store APICookieAPI
- Cookie相關Cookie
- cookie 簡介Cookie
- JavaScript 建立CookieJavaScriptCookie
- Postman同步cookiePostmanCookie
- Cookie簡介Cookie
- session和cookieSessionCookie
- cookie&sessionCookieSession
- Session與CookieSessionCookie