views:

107

answers:

6

Dear All
I'm having a problem with cookies, if the browser has cookies disabled, the cookie gets rejected. Is there a way enable cookies on the clients browser, that is compatible with IE, Firefox ,Opera and Chrome?

+3  A: 

If that would be possible, it’d be a security flaw. So no, it is not possible.

Gumbo
+3  A: 

I'm not aware of one and would be suprised if there was one - people turn cookies off for (among other things) security reasons, so allowing the site to re-enable them would be a security issue.

What you could do is to write some logic into your app to check for cookies:

First

set a cookie called 'test';
redirect the user to http://wherevertheywere?cookiecheck=1

Then, include logic like this:

if the querystring contains cookiecheck=1:
  if the 'test' cooke is set
    cookies are working - do whatever you need to do.
  else
    redirect the user to a special page on your site explaining that they need to enable cookies to use the site. This can include browser detection to give them relevant instructions,
benlumley
+1 for the example code.
Unkwntech
+9  A: 

If a user has chosen to disable cookies, who are you to override that choice?
The best thing to do is notify the user that they need to enable cookies for your script/site to work and provide a link to some instructions on how to do so.
Or find a different way to achieve what you are trying to do

meouw
A: 

I think there isn't a way to do this.

Hope there isn't a way to do that, too.

If user disabled cookie there is a reason to do this and re-enabling them should be filed as a security flaw

Eineki
+2  A: 

If cookies are not enabled or supported by the browser, you should have your software use an alternative way of maintaining sessions from page-to-page. You may have to include a session key as a URL parameter. Just make sure you have aggressive session key validation. Depending on your language and environment, there may already be facilities for doing this that won't add a lot of development overhead (PHP $_SESSION, for one).

Nolte Burke
A: 

It is probably possible, but there are so many browsers in so many versions that you'd be hard pressed to cover a reasonable number of scenarios.

Further, if the user has disabled cookies, turning them on for the user and using them would be criminal interference with their computer.

Adam Hawes