我能够通过Mule ESB在请求的响应中添加1个cookie.但是,当我尝试使用属性"Set-Cookie"添加多个cookie时,Mule会覆盖第一个cookie并返回第二个cookie.
例如,在下面的代码片段中,我在message属性上添加了2个cookie(这是一个映射).
`String msg = "SSID=123;domain=localhost;Path=/";
String msg2 = "SSAPID=456;domain=localhost;Path=/";
message.setProperty(HttpHeaders.Names.SET_COOKIE,msg, PropertyScope.OUTBOUND);
message.setProperty(HttpHeaders.Names.SET_COOKIE,msg2, PropertyScope.OUTBOUND);
`
Run Code Online (Sandbox Code Playgroud)
当我收到回复时,只有一个cookie:
Message properties:
OUTBOUND scoped properties:
Set-Cookie=SAPID=456
access-control-allow-credentials=true
access-control-allow-headers=Origin, X-Requested-With, Content-Type, Accept, Cache, X-Auth-Token
access-control-allow-methods=PATCH, PUT, POST, GET, OPTIONS, DELETE
access-control-allow-origin=*
access-control-max-age=10
cache-control=no-store
content-encoding=gzip
content-type=application/json;charset=UTF-8
date=Wed, 13 Jan 2016 12:26:58 GMT
http.reason=OK
http.status=200
pragma=no-cache
server=Apache-Coyote/1.1
transfer-encoding=chunked
vary=[Accept-Encoding, Accept-Encoding]
x-content-type-options=nosniff
x-xss-protections=1; mode=block
SESSION scoped properties:
Run Code Online (Sandbox Code Playgroud)
Set-Cookie = SAPID = 456
如您所见,请求中仅返回了第二个cookie.
我怎样才能实现我想做的事情,因为这里描述的cookie规范https://tools.ietf.org/html/rfc6265#section-3.1说我可以在响应中返回超过1个Set-Cookie头.
服务器可以通过返回两个Set-Cookie头字段来存储会话标识符以及用户的首选语言
这里它基本上说:在你的应用程序的渲染器代码中,只需要这个包....
我不知道放在哪里.当我把它放在main.js时,我的应用程序就不会再启动了.我正确安装它,因为它在我的node_modules文件夹中.有任何想法吗?
我的main.js:
'use strict';
const electron = require('electron');
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
function createWindow () {
require('electron-cookies');
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600,nodeIntegration:false});
// and load the …Run Code Online (Sandbox Code Playgroud) 通常我会用来cookies将数据从一个AngularJS应用程序解析到另一个应用程序,然后在bootstrapping我的应用程序之前读取这些cookie .
这种方法的问题在于cookie具有大小限制.为了解决这个问题,我想到了$localstorage从ngStorage图书馆使用.
现在我的问题是,如何$localstorage在bootstrapping应用程序之前读取存储在我的数据,即:纯粹JavaScript?
我有一个问题.当我想用布尔值设置Cookie时(只是假值)它不存储.
setcookie('myCookie',false);
Run Code Online (Sandbox Code Playgroud)
即使我添加到期时间
setcookie('myCookie',false,time()+3600);
Run Code Online (Sandbox Code Playgroud)
注意:未定义的索引:第4行的C:\ xampp\htdocs\Web\php\php_global_user.php中的myCookie
<script type="text/javascript">
function WorldwideSellingModelCookie(){
days=7;
myDate = new Date();
myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
document.cookie = 'WorldwideSellingModelCookie=Accepted; expires=' + myDate.toGMTString();
}
function CheckCookies(){
var worldwideSellingCookie = getCookie("WorldwideSellingModelCookie");
if (worldwideSellingCookie == "Accepted")
{
jQuery(".alert-worldwide").hide();
}
}
CheckCookies();
</script>
Run Code Online (Sandbox Code Playgroud)
你好
正在创建cookie,我只是不确定如何在我的CheckCookies函数中使用if语句,以便在页面上隐藏div?
我收到以下控制台错误:
未捕获的ReferenceError:未定义getCookie
谁能告诉我我在做什么错?
谢谢
更新:
<script type="text/javascript">
function WorldwideSellingModelCookie(){
days=7;
myDate = new Date();
myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
document.cookie = 'WorldwideSellingModelCookie=Accepted; expires=' + myDate.toGMTString();
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c …Run Code Online (Sandbox Code Playgroud) 当我尝试进入"if cookie exists then redirect"功能时,它不会进入.
#!/usr/bin/perl -I/srv/www/abc/m/www
require "api";
my $db = db();
use CGI;
use DBI;
use strict;
use warnings;
#use CGI qw( :standard -nph );
# read the CGI params
my $cgi = CGI->new;
my $cookie = $cgi->param("loggedin");
#my $cookie = $cgi->cookie("loggedin");
if ( $cookie ) {
print $cgi->redirect("http://host.com");
exit;
}
...
if ( $userID ) {
$cgi->cookie( -name => 'loggedin', -value => '1' ,-expires => '+4h', -path => '/' );
print $cgi->redirect("http://host.com");
exit;
}
Run Code Online (Sandbox Code Playgroud)
我想确定我在页面底部设置的cookie是否存在,如果存在,则执行重定向.此代码在if …
这是我的tomcat-users文件的样子:
<tomcat-users>
<role rolename="admin"/>
<role rolename="analyst"/>
<role rolename="user"/>
<role rolename="kie-server"/>
<role rolename="developer"/>
<role rolename="manager"/>
<user username="w" password="w" roles="admin"/>
<user username="k" password="k" roles="kie-server"/>
<user username="u" password="u" roles="user,developer,analyst"/>
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)
在KIE IDE WORKBENCH中输入正确的凭据后,出现以下异常:
java.lang.IllegalArgumentException: An invalid character [34] was present in the Cookie value
org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateCookieValue(Rfc6265CookieProcessor.java:182)
org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:115)
org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
org.apache.catalina.connector.Response.addCookie(Response.java:967)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
org.uberfire.ext.security.server.SecurityIntegrationFilter.doFilter(SecurityIntegrationFilter.java:61)
Run Code Online (Sandbox Code Playgroud) 我正在学习PHP最重要且最难理解的概念."会话和Cookie"
根据我的理解,cookie只能通过使用setcookie()或者setrawcookie()函数设置到浏览器中.
根据我对会话过程的理解,它以下列方式工作.
PHPSESSID.要在我的PHP代码中引用会话ID,我会引用变量$ PHPSESSID(它是一个cookie名称)如果我在以上解释中的任何地方理解错误,请纠正我.
我怀疑是因为会话在$_COOKIE超全局中设置了一些价值,它无处使用任何函数,setcookie() or setrawcookie()那么会话ID如何被存储为cookie变量?
如果我假设会话ID被设置为cookie变量并且setccookie() or setrawcookie()可能已在内部调用,那么在调用任一函数 setccookie() or setrawcookie()设置cookie值时设置的参数值是多少?
谢谢.
我有一个登录服务,当我登录时,它将用户登录信息传递给我的应用程序.这将在成功登录时调用我的应用程序的第一页.用户信息作为此请求中cookie的一部分传递.
我正在尝试使用以下代码在我的Web API请求中从请求中读取这些cookie.
CookieHeaderValue getAccessUserInfo = request.Headers.GetCookies("GAUSERINFO").FirstOrDefault();
if (getAccessUserInfo != null)
{
userInfo = getAccessUserInfo["GAUSERINFO"].Values.Get("corporate_id");
Logger.Info(string.Format("User Cookie {0}", userInfo));
return userInfo;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我试图从javascript或角度js读取相同的cookie,我无法在集合中看到该cookie.下面是我用来读取角度js中的cookie的代码.
console.log($document[0].cookie);
Run Code Online (Sandbox Code Playgroud)
这是我可以从结果中看到的cookie.我期待的cookie是GAUSERINFO以及下面的cookie.
有没有办法从角度js或请求正文的至少传递读取这些cookie,以便我可以使用C#代码读取我的API中的cookie.
我在这篇文章中找到了解释仅使用HTML设置cookie的方法。
他在HTML文档http-equiv的<meta>中使用属性<head>:
<meta http-equiv="set-cookie" content="___________">
Run Code Online (Sandbox Code Playgroud)
现在,我已经阅读了有关HTML <meta> http-equiv属性的信息,但是我不明白如何使用它来设置cookie。
有人可以向我解释是否可以使用此方法设置Cookie,或者该指南只是一个玩笑?我尝试了此操作,但HolidayGlaze尚未保存cookie。
<meta http-equiv="set-cookie" content="HolidayGlaze=Good%20yummies; expires=Sat, 25-Nov-2023 12:00:00 GMT; domain=.example.com; path=/; secure; httponly;">
Run Code Online (Sandbox Code Playgroud)
PS我还阅读了有关HTML 4.01和HTML5语法之间的区别的信息,因此我的问题是有关HTML5的正确语法的。