cookie

python - get cookie expiry time using the requests library

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to get the expiry time of a specific cookie that I retrieve from the server as: s = requests . session () r = s . get ( "http://localhost/test" ) r . cookies This will list all cookies sent by the server (I get 2 cookies) as: < <class 'requests.cookies.RequestsCookieJar' > [ <Cookie PHPSESSID = cusa6hbtb85li8po argcgev221 for localhost . local /> , <Cookie WebSecu = f for localhost . local / test > ]> When I do: r . cookies . keys I get: <bound method RequestsCookieJar.items of < <class 'requests.cookies.RequestsCooki

How to use Cookies in HttpURLConnection for ANDROID?

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to create an Application for Asterisk Interface, the configuration setup has been done properly as I have double checked it. It seems the reason why I can't access Config files from Asterisk server has to do with the connection. I need to use a cookie for connecting to the same instance of the login session. But so far I am unable to use Cookie Properly need a little help. I am supposed to login by pressing button1 (bt1) and get config file by pressing button2 (btn2). public class AsteriskInterface extends Activity { private

Servlet 会话

风流意气都作罢 提交于 2019-12-03 09:44:44
在网络的七层模型中,会话层位于传输层之上,它定义如何开始、控制和结束一个会话。七层模式目前仅仅处于理论阶段,但是Web中借鉴了其中的一些思路。在Web中浏览器第一次发送请求到服务器开始直到一方断开为止算作一个会话。HTTP协议本身没有状态,那么Web服务如何知道这次请求是否在一个会话中呢?Web提供了Cookie和Session两种技术。 服务器在第一次收到请求之后,会在HTTP响应头的 Set-Cookie 中,设置Cookie值,浏览器收到响应后,保存这个Cookie在本地。后续再进行请求的时候在HTTP的请求头中设置 Cookie 值,服务器根据此Cookie来识别请求的状态。 Cookie值本身是一个键值对,例如 Cookie: name=value; Servlet 使用Cookie 在Servlet中,使用Cookie的步骤如下: 创建Cookie对象 new Cookie(String name, String value) 发送cookie到浏览器 response.addCookie(Cookie) 获取浏览器中发送过来的cookie request.getCookies() 返回所有Cookie 遍历Cookies 获取所有cookie对象 调用 Cookie.getName() , Cookie.getValue() 获取Cookie中的键和值

cookie和session了解吗

岁酱吖の 提交于 2019-12-03 09:40:13
Cookie 和Session是什么? 彻底搞懂cookie的运行原由? 什么时候不能用Cookie,什么时候不能用Session session在什么时候创建,以及session一致性问题 Cookie和Session的区别: 1.COOKIE的由来:因为HTTP请求时没有状态的,每一次请求都是独立的,它不会受前面的请求响应情况直接影响,也不会直接影响后面的请求响应情况。2.cookie就是保存在浏览器上的键值对服务器控制着响应,在响应里可以让浏览器在本地保存键值对,下次请求再发送的时候就会自动携带这个cookie值。浏览器关闭,cookie就失效3.cooie的应用:1.七天免登陆 2.记录用户的浏览器习惯 3.简单的投票规则4.服务端: 1. 生成字符串 2. 随着响应将字符串回复给浏览器 3. 从浏览器发送的请求中拿到字符串好处: 服务端不用存,减轻了服务器压力坏处: 信息不安全session:保存在服务端的键值对,必须依赖于cookie在服务器端存在的形式 sadsjhsjkcehhw:{"is_login":1,"user":"jerd"} (1)深入理解Cookie cookie是客户端浏览器存储的 K-V键值对,用来接收服务端响应的set-cookie()字符串,用cookie可以设置域domain,指定路径的cookie,设置了属性secure

如何在Spring Boot中使用Cookies

夙愿已清 提交于 2019-12-03 09:18:46
一、 导读 本文大纲 读取HTTP Cookie 设置HTTP Cookie 读取所有Cookie[] 为Cookie设置过期时间 Https与Cookie HttpOnly Cookie 删除Cookie HTTP Cookie(也称为 Web cookie , 浏览器cookie )是服务器在用户浏览器中存储的小部分数据。服务器端应用程序在返回浏览器请求响应的时候设置cookie,浏览器存储cookie,并将它们在下一个请求一起发送的时候自动带回服务器端应用程序。 Cookies提供了一种在服务器和浏览器之间交换信息的方法,以管理会话(登录,购物车,游戏得分),记住用户首选项(主题,隐私策略接受)以及跟踪整个站点的用户行为。Cookies在一定程度上解放了服务器端的压力,因为将一部分数据放在浏览器端存储,所以这部分数据不能是涉及应用安全的数据。在本文中,我们将学习如何在Spring Boot应用程序中读取、设置和删除HTTP cookie。 二、读取HTTP Cookie Spring框架提供 @CookieValue 注释来获取HTTP cookie的值,此注解可直接用在控制器方法参数中。 @GetMapping("/") public String readCookie(@CookieValue(value = "username", defaultValue =

Set new cookie between requests with Python Requests

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm doing this right now, but it fails at that last line with TypeError: expected string or buffer . import requests from urllib.parse import urlparse url = 'some url' s = requests.Session() s.headers.update({ 'Origin':urlparse(url).netloc, 'Referer':url }) r = s.get(url) s.cookies['cookie1'] = 25 s.cookies['cookie2'] = 25 r = s.post( url, {'param':'value1', 'param2':'value2'}, headers={'X-Requested-With':'XMLHttpRequest'} ) What's the correct way to update the cookies when using Session ? I'm pretty new to Python, so I might have confused

PHP Save Session when using session_write_close();

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've one page where i do a long polling i've to use at the begin of this page this session_start(); session_write_close(); Because : to prevent concurrent writes only one script may operate on a session at any time So if i do not and the long polling is running the user will not be able to load another page. So accessing to my data in session from this polling page is possible but at some point in my script i've to save my session back to the server because i made some change in it. What's the way to do it? That will be very nice it'll be a

PHP - Using cURL to store cookie session into variable / memory

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to avoid cURL storing the cookie session into an actual file via "CURLOPT_COOKIEJAR". So I created a method to catch / parse the cookies into a local variable - which is then used via "CURLOPT_COOKIE" to restore the cookie session. I cut out the cookies via preg_match_all ( "/^Set-cookie: (.*?);/ism" , $header , $cookies ); To use "CURLOPT_COOKIE" we take the key=value and separate them via "; ". However (As I'm aware), CURLOPT_COOKIE doesn't allow you throw in various flags I.e. expiration, secure flag, and so on.

Session机制详解及分布式中Session共享解决方案

旧巷老猫 提交于 2019-12-03 08:54:49
一、为什么要产生Session   http协议本身是无状态的,客户端只需要向服务器请求下载内容,客户端和服务器都不记录彼此的历史信息,每一次请求都是独立的。   为什么是无状态的呢?因为浏览器与服务器是使用socke套接字进行通信,服务器将请求结果返回给浏览器之后,会关闭当前的socket链接,而且服务器也会在处理页面完毕之后销毁页面对象。   然而在Web应用的很多场景下需要维护用户状态才能正常工作(是否登录等),或者说提供便捷(记住密码,浏览历史等),状态的保持就是一个很重要的功能。因此在web应用开发里就出现了保持http链接状态的技术:一个是cookie技术,另一种是session技术。 二、Session有什么作用,如何产生并发挥作用   要明白Session就必须要弄明白什么是Cookie,以及Cookie和Session的关系。   1、什么是Cookie   Cookie技术是http状态保持在客户端的解决方案,Cookie就是由服务器发给客户端的特殊信息,而这些信息以文本文件的方式存放在客户端,然后客户端每次向服务器发送请求的时候都会带上这些特殊的信息。   2、Cookie的产生   当用户首次使用浏览器访问一个支持Cookie的网站的时候,用户会提供包括用户名在内的个人信息并且提交至服务器;接着,服务器在向客户端回传相应的超文本的同时也会发回这些个人信息

Codeigniter sessions across sub domains

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have multiple subdomains and i'm trying to use the sessions across subdomains. http : //example.com http : //subdomain.example.com I have also set the cookie domain in config.php $config [ 'cookie_domain' ] = ".example.com" ; The session userdata and also flashdata are empty when used in the other domain. Im using the same session table as well for both CI instance 回答1: From the following solution : Sharing sessions Both the cookie_domain and cookie prefix has to be set $config [ 'cookie_domain' ] = ".example.com" ; $config [