[Cppcms-users] The role of cookie path
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2016-07-08 10:24:50
|
Server configuration follows:
"session":{
"location":"client",
"cookies":{
"prefix":"prefix"
//"path":"/"
},
}
Browser shows that the path of every cookie is set to "/" by
session().set("name","value"). So far so good.
This is server debugging code:
for(auto const &c : request().cookies())
BOOSTER_DEBUG("COOKIES") << c.first << ":" << c.second.path();
BOOSTER_DEBUG("mc") << session().is_set("my_cookie");
Client requests for URL "http://localhost/normal" and above server code
writes the following log as expected except for one thing -
cookie.path() returning empty string:
2016-07-08 17:35:31; COOKIES, debug: prefix:
2016-07-08 17:35:31; COOKIES, debug: prefix_c1:
2016-07-08 17:35:31; COOKIES, debug: prefix_my_cookie:
2016-07-08 17:35:31; mc, debug: 1
Question: Is it by design that cookie.path() returns empty string here?
Now, after client gets the page from "http://localhost/normal", it calls
this javascript:
window.location.replace("http://localhost/special");
the same above server code now writes these log:
2016-07-08 17:35:31; COOKIES, debug: prefix:
2016-07-08 17:35:31; COOKIES, debug: prefix_c1:
2016-07-08 17:35:31; COOKIES, debug: prefix_my_cookie:
2016-07-08 17:35:31; mc, debug: 0
indicating that cookie "my_cookie" is not set.
I am puzzled by the behavior of cookies -
request().cookies() indicates that cookie "my_cookie" exists
but session().is_set("my_cookie") says it doesn't.
How can it be so?
Is the empty cookie.path() making the trouble?
Best Regards,
CN
--
http://www.fastmail.com - A fast, anti-spam email service.
|