我有一些IE8尊重我通过jQuery cookie插件设置的cookie的问题.在Firefox,Chrome,Safari,IE6和IE7(通过IETester)中,一切正常,但IE8似乎并没有存储cookie.
如果我F12到开发工具栏并检查"缓存"菜单项中的cookie,我可以在设置后看到我的cookie.我还看到其他cookie被设置但我只有我的测试页面作为我的主页.我有一堆用于microsoft和coolwebdeveloper.com的cookie(我把那个网站拉了起来,不记得曾经去过那里)???
下面是我通过开发工具栏设置/验证的cookie.
NAME filters
VALUE show
DOMAIN mydomain.com
PATH /my/neat/path/
EXPIRES 3/12/2011 6:30:02 PM
Run Code Online (Sandbox Code Playgroud)
当我退出/重新启动IE8时,该cookie不会持续存在(它将在31天后过期).
有人有主意吗?我可以查看一些偏好设置吗?这可能是一些IT设置/防火墙的事情,我无能为力吗?
我确实尝试了选项 - >隐私 - >将互联网区域降低到"接受所有cookie",但这并没有什么不同.不过,我在屏幕底部有一个突出显示的注释,"某些设置由系统管理员管理".
另外,在View - >网页隐私政策中,我正在测试的域名称"没有限制或阻止cookie".
更新 cookie 值而不更改其到期日期?
$c = $_COOKIE["count"];
$c++;
if (isset($_COOKIE["count"])) {
setcookie("count", $c);
}
else
{
setcookie("count", $c, time() + 86400, '/');
}
Run Code Online (Sandbox Code Playgroud) 我正在构建一个Android应用程序,我很好奇什么是会话管理的"最佳实践".
我将我的应用程序设置为进行身份验证(以google-play-services).我想存储会话ID并在用户离开应用程序时使其过期.cookie是最好的方法吗?还有更好的选择吗?任何示例代码都非常有用.
谢谢,克雷格
我使用 HTTParty 来发出 HTTP 请求并使用 REST API。现在我想重新使用我通过 POST 调用的登录页面设置的 cookie。
class SomeImporter
include HTTParty
def self.login
response = self.post('https://www.example.com/login', :query => {:user => 'myusername', :password => 'secret'})
self.default_cookies.add_cookies(response.header['set-cookie'])
self.get('https://www.example.com/protected')
end
end
Run Code Online (Sandbox Code Playgroud)
使用此代码未正确设置 cookie。如何正确解析 HTTParty 给出的“set-cookie”标头并为下一个请求设置 cookie?
ruby-on-rails setcookie session-cookies httparty http-headers
我的网站上有两个以上的子域名.例如:www.example.com,login.example.com,user.example.com,cart.example.com ...我设置cookie_domain是config.yml中的.example.com和php.ini当我setCookies( 'test','value','.example.com'),但cookie始终不在子域中共享.那么,现在该怎么办?
有我的config.yml
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/"
cookie_domain: .example.com
cookie_lifetime: 0
name: TESTSESSIONID
Run Code Online (Sandbox Code Playgroud)
在我的安全:
security:
session_fixation_strategy: none
Run Code Online (Sandbox Code Playgroud) 这是来自较大应用程序的示例脚本,但显示了我正在尝试执行的操作的一般过程。如果我有以下脚本:
<?php
ob_start();
setcookie('test1', 'first');
setcookie('test1', 'second');
setcookie('test1', 'third');
setcookie('test2', 'keep');
//TODO remove duplicate test1 from headers
ob_end_clean();
die('end test');
Run Code Online (Sandbox Code Playgroud)
我得到以下响应(通过 Fiddler 查看):
HTTP/1.1 200 OK
Date: Tue, 25 Apr 2017 21:54:45 GMT
Server: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.5.30
X-Powered-By: PHP/5.5.30
Set-Cookie: test1=first
Set-Cookie: test1=second
Set-Cookie: test1=third
Set-Cookie: test2=keep
Content-Length: 8
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
end test
Run Code Online (Sandbox Code Playgroud)
问题是Set-Cookie: test1......存在3次不同的时间,因此不必要地增加了标题大小。(同样,这是一个简化的示例 - 实际上,我正在处理 ~800 字节范围内的 ~10 个重复 cookie。)
有什么我可以写的东西来代替TODO完全摆脱标题的东西,或者它只显示一次?即以下是我的最终目标:
HTTP/1.1 200 OK
Date: Tue, 25 …Run Code Online (Sandbox Code Playgroud) 我想要实现的目标是存储来自网站的cookie,然后在第二时刻使用它们.这是代码:
保存cookie
let cookie = await page.cookies();
cookie = JSON.stringify(cookie);
fs.writeFile("cookie.txt", cookie, function(err, data){
if (err) {
console.log(err);
} else {
console.log("Successfully Written to File.");
}
});Run Code Online (Sandbox Code Playgroud)
阅读Puppeteer中的cookie
await page._client.send("Network.clearBrowserCookies");
await injectCookiesFromFile("cookie.txt", page)
async function injectCookiesFromFile(file, page) {
let cb = async function (_cookies) {
console.log("Injecting cookies from file: %s", JSON.stringify(_cookies) );
//await page.setCookie(..._cookies); // method 1
await page.setCookie(_cookies); // method 2
};
fs.readFile(file, async function(err, data) {
if(err) {
throw err;
}
let cookies = JSON.parse(data);
console.log(cookies);
//await cb(cookies); …Run Code Online (Sandbox Code Playgroud)cookies setcookie google-chrome-devtools google-chrome-headless puppeteer
我正在尝试获取请求,但我需要放入cookie。
使用curl可以:
curl -v --cookie "sessionid=asdasdasqqwd" <my_site>
但是下面的功能没有带来什么
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart';
...
parseHtml() async {
http.Response response = await http.get (
<my_site>,
headers: {"sessionid": "asdasdasqqwd"}
);
Document document = parser.parse (response.body);
print(document.text);
}
Run Code Online (Sandbox Code Playgroud)
有没有办法将Cookie放在Dart中的get请求上?
我正在尝试设置一个 nginx 服务器,当点击某个位置时,它会在 cookie 中设置某些参数。
我有以下配置将参数放入 cookie 但过期不起作用。这是我的配置:
server {
listen 8800 default_server;
include /etc/nginx/default.d/*.conf;
server_name test.net;
location /initial {
add_header Set-Cookie lcid=1043;
add_header Set-Cookie expires=60;
}
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解,设置此 cookie 60 秒后,cookie 应该会过期并被删除。然而,它仍然存在。
这个配置有什么问题吗?
任何帮助将不胜感激,谢谢!
我正在尝试将 Spring Boot 配置为在来自我的 React 应用程序的登录请求之后设置包含 JWT 身份验证令牌的 cookie,然后期望浏览器会自动将此 cookie 设置为 cookie 路径指定的所有请求。行为在我朋友的环境中没问题 - 相同的代码,Chrome 浏览器,不同的机器。我尝试清除 node_modules,mvn clean install,还尝试了不同的浏览器 Chrome 和 FireFox,但没有成功。
这是所有相关的代码(如果我遗漏了其他重要的东西,请告诉我)
package.json 中有一个代理
"proxy": " http://localhost:8080 ",
为了测试身份验证流程,我们从登录表单 (react) 发出登录请求,该请求成功代理到端口 8080,并且来自服务器的响应成功返回 JWT 令牌作为身份验证 cookie 的一部分。cookie 被指定为/api路径。如下 Chrome 中所示的网络请求:
登录后,react 应用程序立即向后端发出第二个 HTTP 请求,但服务器上的断点显示没有 cookie 作为此请求的一部分从浏览器传递。请求是http://localhost:3000/api/user。
在前端,我们fetch用来发出该请求,它看起来像这样:
fetch("/api/user, {
credentials: "same-origin"
})
Run Code Online (Sandbox Code Playgroud)
仅作为附加上下文,这是我们在成功登录后从服务器返回原始 cookie 的方式:
@PostMapping("/signin")
public ResponseEntity signin(@RequestBody AuthenticationRequest data, HttpServletResponse response) {
try …Run Code Online (Sandbox Code Playgroud) setcookie ×10
cookies ×6
http-headers ×2
php ×2
android ×1
dart ×1
httparty ×1
nginx ×1
nginx-config ×1
puppeteer ×1
reactjs ×1
request ×1
session ×1
spring-boot ×1
symfony ×1