华敏
huamin
全部博文(17)
jsp(1)
JDBC(0)
SQL-HQL-EQL(0)
Corejava(1)
oracle(0)
HTML(0)
structs+Spring+h(0)
JAVA(10)
2009年(1)
2008年(16)
wb123456
gaokeke1
smile124
北冥大鱼
Mercess
biwangsh
12729816
robin_32
beaning_
分类: Java
2009-01-16 17:53:21
添加cookie
Cookie addMyCookie = new Cookie("usID",234234);
addMyCookie.setMaxAge(-1); // 60*60*24*365 cookie 的对大有效期,秒为单位
//----------------------------------------------------------
public class CookieValue { private CookieValue() {} public string username; public string usercard; public string userid public static CookieValue GetInstanceFromCookie(string cookiename) { CookieValue value = null; HttpCookie cookie = HttpContext.Current.Request.Cookies[cookiename]; if(cookie != null) { value = new CookieValue(); value.username = cookie.Values[ "username "]; ......以下相同复制另两个字段 return value; } return value; } } ---------调用 CookieValue value = CookieValue.GetInstanceFromCookie(cookie名);
//---------------------------------------------------------------
Cookie[] cookies = request.getCookies(); if (cookies != null){ for(int i=0;i Cookie c = cookies[i]; if(c.getName().equals("usID")){ checkCookie = true; } }
上一篇:div 页面元素居中
下一篇:没有了
登录 注册