设置session实效时间问题5

public String getCookieValue(
HttpServletRequest request,
String cookieName) {

// if (cookieValues == null || cookieValues.isEmpty()){
Cookie[] cookies = request.getCookies();
//System.out.println(" cookies "+cookies.toString());
cookieValues = new HashMap();
// cookies[0]=new Cookie(LoginConstants.LOGIN_FLAG
// ,"aaaaaa");


if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookieValues.put(cookie.getName(), cookie.getValue());
}
}
//}
logger.info("in cookie "+cookieValues.get("in"));
return (String) cookieValues.get(cookieName);
}
/**
* 验证用户(通过验证返回true,否则返回false)
* @param (String)uid 用户id
* @param (String)pwd 用户密码
* @return boolean ture or false
* @author skf4865
* @add date 2004-11-21
*/
private boolean validUser(String uid, String pwd) {
try {
UserManageDelegate umDelegate =
new UserManageDelegate(UserInfoBean.INTRANET_USER);
return umDelegate.checkPasswordValue(uid, pwd.getBytes());
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
/**
* 删除cookie
* @param request
* @param response
*/
private void killCookie(
HttpServletRequest request,
HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookie.setValue(null);
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
}
/**
* 导向登录页面,登陆服务器向用户浏览器中写入了
* lang cookie value :en
login_logFlag in /out
login_sid session id
login_uid 用户名
login_cip 客户IP
login_cname 客户名
login_sip 登陆服务器IP
JSESSIONID
* @param request
* @param response
* @throws IOException
*/
private void redirect2Login(HttpServletRequest request,HttpServletResponse response)throws IOException {
String url = request.getRequestURL().toString();

String queryStr = request.getQueryString();
if (queryStr != null){
url = url + "?" + queryStr;
}
if (url != null) {
//url = URLEncoder.encode(url,"UTF-8");
url = URLEncoder.encode(url);
response.sendRedirect("http://login.huawei.com/login/forwardLogin.do?redirect="+ url);
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值