If I already set SSL for my application server, do I still need to set HttpOnly for the cookies?
Asked
Active
Viewed 9,498 times
1 Answers
20
Yes. The two flags have nothing to do with each other (both are security/privacy options, though)
"Secure" means that the cookie will only be sent over encrypted connections
"HttpOnly" means that the cookie will not be visible to Javascript
You could still have XSS on an HTTPS page, for example (and then an evil script could eat your cookie).

Thilo
- 257,207
- 101
- 511
- 656
-
As I understand, the purpose of stealing cookie here is for session hijacking. If SSL is enabled, session hijacking is not possible? (Am I correct here?) – ysp80 Dec 23 '11 at 03:24
-
With XSS, you can have malicious Javascript to read the session cookie. You can then send it to another server (for example by creating a hidden image tag with the cookie value in the URL) and hijack the session. – Thilo Dec 23 '11 at 03:26
-
-
Yes, if you are using session cookies only (and not additional other factors like client IP, HTTP authentication or client certificates), then you can hijack the session by getting the cookie, even when SSL is enabled. SSL just makes sure you don't get the cookie by sniffing the network. – Thilo Dec 23 '11 at 03:37