Cookie domain not set

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cookie domain not set

Mathieu Gond
Hello Everybody,

We are trying to read Cookies (getRequest().getCookies()) in a ServerResource and We can't get the domain (getDomaine()) because it is not set.

Is there a reason that it is not set or is it a bug (We are using restlet JavaSE 2.0.5)

Thanks in advance

Mathieu and Thierry

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3069051
Reply | Threaded
Open this post in threaded view
|

Re: Cookie domain not set

Thierry Boileau-4
Hello,

I've made some tests and notice that the browser (at least Firefox and chromium) doesn't send the domain data in the cookie header. Thus the value is not set at the cookie level.
If you really need the domain, you can infer it from the request's reference:
request.getResourceRef().getHostDomain()

By doing do, you will get the full name of the request's domain.

If you still need to read the domain from the cookie inside the code of your resources, you can also add a filter in front of your resources that completes the current cookies, and add the domain parameter taken from the request's reference.

Best regards,
Thierry Boileau

ps :
// First server response, that requires the browser to record a cookie.
HTTP/1.1 200 OK
Content-Length: 12
Content-Type: text/plain; charset=UTF-8
Date: Thu, 05 Dec 2013 09:02:04 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/@major-number@.@minor-number@@release-type@@release-number@
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Set-Cookie: test=myvalue; Domain=.tboi.net
 
hello, world

// Second client request, note the "cookie" header, without domain data.
GET /hello HTTP/1.1
Host: yop.tboi.net:8888
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:25.0) Gecko/20100101 Firefox/25.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: test=myvalue
Connection: keep-alive
Cache-Control: max-age=0



2013/11/22 Mathieu Gond <[hidden email]>
Hello Everybody,

We are trying to read Cookies (getRequest().getCookies()) in a ServerResource and We can't get the domain (getDomaine()) because it is not set.

Is there a reason that it is not set or is it a bug (We are using restlet JavaSE 2.0.5)

Thanks in advance

Mathieu and Thierry

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3069051