Tag: session cookies

检查cookie存在使用jquery / js登录注销

我有一个DNN登录/注销控件,它无法正常工作。 因此,我想使用JS / JQUERY进行自己的操作。 当用户登录时,页面上的HTML如下所示: Logout 当它们“退出”时,它看起来像这样: https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login 我想检查cookie是否已设置,是否已显示https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Logoff链接,如果没有,则显示https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login链接。 单击https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login将检查cookie是否存在(它应该显示为https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login)并将其带到登录页面。 单击https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Logoff应该删除cookie并刷新页面,然后再次将链接更改回“https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login”,因为没有找到cookie。 我使用它作为示例指南: http : //jsfiddle.net/MadLittleMods/73vzD/ 这是我到目前为止所做的: HTML: https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login || https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Logoff see JS: //set the cookie once user has logged in //for testing purposes clicking login should set the cookie to 1 //clicking on https://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Logoff ‘should’ set the cookie to 0 $(‘#dnn_dnnLOGIN_cmdhttps://stackoverflow.com/questions/10102483/checking-a-cookie-exists-login-logoff-using-jquery-js/Login’).live(‘click’, function() { var action […]

为什么Rails无法在Internet Explorer的Ajax请求中访问会话?

我在sessions_helper中有以下代码: def current_user @current_user ||= User.find_by_remember_token(cookies[:remember_token]) end 这让我从任何控制器调用current_user来获取当前用户。 (我从头开始使用类似于Railstutorial或Railscasts的身份validation)。 我有一个名为lookup_result ajax请求,它检查服务器以查看特定结果是否已准备就绪。 $.get(“/lookup_result?id=”); 它转到以下控制器方法: def lookup result user = current_user # do things with user… end 这通常可以正常工作,但有时Rails无法获取current_user。 我怀疑问题是cookie或CSRF令牌在某些情况下无法通过ajax请求传递,但为什么它通常有效? 我如何修复它以便始终有效? 更新: 我不知道如何复制错误。 只有已登录的用户才能访问发送该请求的页面(尽管有人可以将ajax请求复制到另一个未登录的浏览器中)。 我用rollbar报告错误并保存请求数据。 当current_user失败时,这是user-agent的常用数据: Mozilla / 4.0(兼容; MSIE 7.0; Windows NT 5.1; InfoPath.1; …) 这意味着Internet Explorer通过Ajax发送会话信息存在一些问题。 有人知道怎么修这个东西吗? 下面你可以看到它返回的所有数据类别,尽管它对于任何包含“session”的内容都是空的。 时间戳 message.request_data.headers.Accept message.request_data.headers.Accept编码 message.request_data.headers.Accept语言 message.request_data.headers.Cf-Connecting-Ip //(CF代表cloudflare) message.request_data.headers.Cf-Ipcountry message.request_data.headers.Cf雷 […]

Flask会话忘记了请求之间的输入

我正在使用最新的Flask / Werkzeug(Flask 0.9)客户端会话来保持请求之间的信息。 会话未设置为持久性(因为我在浏览器关闭时删除cookie很好)。 我的问题如下: 我使用一些服务器端代码用条目填充Flask会话变量。 在此之后,Session变量看起来像这样: 我使用这些信息将一个执行GET请求的页面(通过JQuery)呈现给同一个Flask应用程序,但突然间,包含会话中“items”条目的字典消失了: 我做了一些搜索,并认为这可能与我在localhost上测试的事实有关(127.0.0.1与localhost不同)。 我修复了我的hosts文件并添加了一个’dev.localhost’条目,以确保所有请求都来自同一主机。 此外,我的浏览器(Chrome)的开发人员窗格显示与发送到服务器的会话Cookie完全相同的标识符。 此外,设置session.modified = True也无济于事。 请求之间唯一的变化是 __utmb=122666782.18.10.1363877633 对于第一个请求(填充items条目的请求)与第二个请求 __utmb=122666782.19.10.1363877633 认为它仍然可能是与Ajax相关的东西。 我在简单的页面重新加载后测试了会话变量的内容: items条目仍然从会话中消失。 任何帮助将不胜感激。

如何清除angular.js中的cookie

目前我正在使用angulajs应用程序。 我想在cookie中存储一些值。 所以我使用angular-cookies-min脚本为cookie添加一些值 我使用下面的代码将值保存到cookie。 $cookieStore.put(“userInfo”, userInfo);//userInfo is a array with some values. 现在我要清除cookie? 我该怎么做?