zoukankan      html  css  js  c++  java
  • Cookie的有效访问路径

    Cookie 的 作用范围: 

    Cookie详解:https://www.cnblogs.com/handsomecui/p/6117149.html

    • 可以作用当前目录和当前目录的子目录. 但不能作用于当前目录的上一级目录. 
    • void setPath(java.lang.String uri)   :设置cookie的有效访问路径。有效路径指的是cookie的有效路径保存在哪里,那么浏览器在有效路径下访问服务器时就会带着cookie信息,否则不带cookie信息。
    <% 
            Cookie cookie = new Cookie("cookiePath", "CookiePathValue");
            //设置 Cookie 的作用范围:
            String contextPath  = request.getContextPath();
         //如果web项目没有指定 Application context 给它一个默认值“/”,否则设置 Cookie 的作用范围无效
    if(contextPath.trim().equals("")){ contextPath = "/"; } cookie.setPath(contextPath); response.addCookie(cookie);
    %>
  • 相关阅读:
    CCF CSP 201403-2 窗口
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
  • 原文地址:https://www.cnblogs.com/realshijing/p/7868438.html
Copyright © 2011-2022 走看看