在seam 中用cookies,刚开始代码可以向client写cookie。但是读的时候,一直都读不到写的cookie,看http信息头也看不到。但是在firefox中确可以看到cookie信息。

今天把cookie.setSecure(true) 给干掉了。得。 一下子全好了。NND

 

@In
protected javax.faces.context.FacesContext facesContext;
..
.....


    
private String getCookies(String name){
        Cookie[] cookies 
= ((HttpServletRequest)facesContext.getExternalContext().getRequest()).getCookies();
        
if(cookies!=null){
            
for(int i=0;i<cookies.length;i++){
                String cn 
= cookies[i].getName();
                
if(cn.equals(name)){
                    
return cookies[i].getValue();
                }
            }
        }
        
return null;
    }
    
    
private void setCookie(String k,String v){
        Cookie cookie 
= new Cookie(k, v);
        cookie.setMaxAge(
3600);
        cookie.setVersion(
32140800);
    
//    cookie.setSecure(true);
        cookie.setPath("/");
        ((HttpServletResponse)facesContext.getExternalContext().getResponse()).addCookie(cookie);
    }

 

Keep-Alive300

Connectionkeep-alive

CookieJSESSIONID=1oqqa4egh88ld; star=chenglong

相关文章:

  • 2021-07-14
  • 2021-10-22
  • 2021-12-29
  • 2022-02-21
  • 2021-05-18
  • 2021-08-19
猜你喜欢
  • 2021-10-04
  • 2021-10-28
  • 2021-08-13
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
相关资源
相似解决方案