How can I detect on the server (server-side) whether cookies in the browser are disabled? Is it possible?
Detailed explanation: I am processing an HTTP request on the server. I want to set a cookie via the Set-Cookie
header. I need to know at that time whether the cookie will be set by the client browser or my request to set the cookie will be ignored.
cookies are always client-side. Session cookies are stored on the client machine and at a minimum contain a reference to the session Id. If a server has a cookie it's because it's acting as a client. You can add cookies with JavaScript or from the server, that's probably what they mean by client vs server cookies.
web servers instruct the client to store a cookie by issuing a special HTTP header, "Set-Cookie". once cookied, every subsequent request by the client to that server will include the HTTP header, "Cookie" with the data that was stored. by default, cookies are deleted when the user quits the browser.
Send a redirect response with the cookie set; when processing the (special) redirected URL test for the cookie - if it's there redirect to normal processing, otherwise redirect to an error state.
Note that this can only tell you the browser permitted the cookie to be set, but not for how long. My FF allows me to force all cookies to "session" mode, unless the site is specifically added to an exception list - such cookies will be discarded when FF shuts down regardless of the server specified expiry. And this is the mode I run FF in always.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With