Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to check if a cookie is httponly in PHP

Is there a way to check if the cookie is httponly in php?

like image 209
malukisses Avatar asked Sep 23 '10 15:09

malukisses


People also ask

How do you check if cookies are HttpOnly?

Press F12, go to the network tab, and then press Start Capturing. Back in IE then open the page you want to view. Back in the F12 window you show see all the individual HTTP requests, select the one that's the page or asset you're checking the cookies on and double click on it.

Can you read HttpOnly cookie?

An HttpOnly cookie cannot be accessed by client-side APIs, such as JavaScript. This restriction eliminates the threat of cookie theft via cross-site scripting (XSS). If the browser allowed you to access it then it would be a defect in the browser.

How do I set the HttpOnly flag on cookies in PHP?

Set HttpOnly cookie in PHP ini_set("session. cookie_httponly", True); This is the most common way to set cookies in PHP, empty variables will hold their default value.

Can you check if HttpOnly cookie exists in JavaScript?

You can indirectly check to see if it exists by trying to set it to a value with javascript if it can't be set, then the HTTP Only Cookie must be there (or the user is blocking cookies).


2 Answers

I don't think that's possible, because this information is not included in the raw headers sent by the browser. In fact, it doesn't make sense to send flags like these back to the server, because they are meaningless to the server and only wastes bandwidth.

like image 90
NullUserException Avatar answered Oct 21 '22 17:10

NullUserException


Well, yes. You'll find it in the array returned by session_get_cookie_params, as long as your PHP is 5.2.0 or newer.

like image 33
djn Avatar answered Oct 21 '22 16:10

djn