JBTALKS.CC

标题: [疑问]Logout的逻辑问题 [打印本页]

作者: duo8668    时间: 2009-10-17 08:29 PM
标题: [疑问]Logout的逻辑问题
想请问各位大大,我的web apps 在 logout 的时候按 Back 时为什么能够看回之前的privacy data呢? 要怎么才能弄得像 Facebook 那样 logout 了就一定 要 login 过才能看回之前本身的资料?本身对 cookies 和 session 有稍微试过, meta header 也disable cache过,就是不行。。。

谢谢!

ASP/PHP/JSP 什么都行。。。
作者: Super-Tomato    时间: 2009-10-17 09:16 PM
原帖由 duo8668 于 2009-10-17 08:29 PM 发表
想请问各位大大,我的web apps 在 logout 的时候按 Back 时为什么能够看回之前的privacy data呢? 要怎么才能弄得像 Facebook 那样 logout 了就一定 要 login 过才能看回之前本身的资料?本身对 cookies 和 ses ...


cookies 或 session 在退出的時候沒有刪除才會這樣
作者: 宅男-兜着走    时间: 2009-10-17 09:17 PM
标题: 回复 #1 duo8668 的帖子
destroy 掉 session 不行吗??
作者: 宅男-兜着走    时间: 2009-10-17 09:19 PM
标题: 回复 #1 duo8668 的帖子
顺便, set 个 function 就是, watch session的, 没fill 到的话就跳页。 通常就可以了。 我记得我老师说过, destroy 了就要从新 fill 过 session 才可以看到。
作者: duo8668    时间: 2009-10-17 09:57 PM
原帖由 Super-Tomato 于 2009-10-17 09:16 PM 发表


cookies 或 session 在退出的時候沒有刪除才會這樣

cookies应该是不能删除的对吗?
我在 jsp 内 invalidate session了。。。按 Back 还是能看见 privacy data。
过后去 asp set cookies date(-1) 也是。。。不行。。。
最后跑去弄 meta disable cache 。。。 结果还是一样。。。

想破脑袋了
作者: duo8668    时间: 2009-10-17 10:00 PM
原帖由 宅男-兜着走 于 2009-10-17 09:19 PM 发表
顺便, set 个 function 就是, watch session的, 没fill 到的话就跳页。 通常就可以了。 我记得我老师说过, destroy 了就要从新 fill 过 session 才可以看到。

destroy session 是不是 invalidate session 的?
我每页都有check session/cookies。。。结果不行。

各位大大有没有试过这种情形呢?
作者: Super-Tomato    时间: 2009-10-17 10:14 PM
原帖由 duo8668 于 2009-10-17 10:00 PM 发表

destroy session 是不是 invalidate session 的?
我每页都有check session/cookies。。。结果不行。

各位大大有没有试过这种情形呢?


把你 login 和 logout 部分的 code 貼出來吧
作者: duo8668    时间: 2009-10-17 10:40 PM
  1.     protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  2.     throws ServletException, IOException {
  3.         response.setContentType("text/html;charset=UTF-8");
  4.         PrintWriter out = response.getWriter();
  5.         try {
  6.             HttpSession session=request.getSession();
  7.             session.invalidate();
  8.             response.sendRedirect("index.jsp");
  9.         } finally {
  10.             out.close();
  11.         }
  12.     }
复制代码
  1.             session = request.getSession(false);
  2.             String validUser = (String) session.getAttribute("validUser");
  3.             //PackagePurchased pp =(PackagePurchased)session.getAttribute("purchase");
  4.             // Details
  5.             String packageID = null;
  6.             String description = null;
  7.             String startDate = null;
  8.             String endDate = null;
  9.             String destination = null;
  10.             double cost = 0;
  11.             String quantity = null;
  12.             String date = null;
  13.             double totalCost = 0;
  14.             Vector v = new Vector();
  15.             PackagePurchased pp;
  16.             int LoginID = 0;
  17.             String LoginName = null;
  18.             if (validUser == null || validUser.equals("NO")) {
  19.                 response.sendRedirect("login.jsp");
  20.             } else {
  21.                 v = (Vector) session.getAttribute("history");
  22.             }
复制代码


谢谢!
作者: Super-Tomato    时间: 2009-10-17 11:04 PM
原帖由 duo8668 于 2009-10-17 10:40 PM 发表
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8") ...


HttpSession.Invalidate();//自己看看 Sun 网站說明
request.getSession(false) //如果不存在则为 null 值
作者: goodday    时间: 2009-10-18 12:47 AM
protected override void Page_Load(object sender, EventArgs e)
    {
        // clear cache
        Response.CacheControl = "no-cache";
        Response.Expires = -1;
        Response.AddHeader("Pragma", "no-cache");

.net 的 意思是 这个网页不要过cache
所有的网页都会存在browse 的cache (temporary internet files)
上面的是存在 ram 里不是在 hdd 理
作者: goodday    时间: 2009-10-18 12:48 AM
http://www.javadocexamples.com/j ... tResponse/addHeader(String%20name,String%20value).html

java 的 sample





欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5