Re: [Cppcms-users] The role of cookie path
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@gm...> - 2016-07-09 12:02:43
|
Browser does not send path information about cookies it sends to
server in HTTP headers, actually it only sends cookie name and value -
not domain, expiration, path or other parameters. Only server does.
That is why you don't get this information in request().cookies() -
server just does not have one.
Artyom
On Fri, Jul 8, 2016 at 1:24 PM, CN <cn...@fa...> wrote:
> 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.
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
|