views:

30

answers:

1

I want to identify on my login page that user browser cookies are disabled, so i can display a message that enable your cookies and then try to login, how to do this? Im using asp.net mvc-2

+1  A: 

The only real way to check if cookies are disabled is to try and store a cookie in the users browser and then retrieve it on a subsequent request.
I think in your situation you should set a cookie when they arrive at the login page. When they submit the login page you can then check to see if the cookie exists in the request. If it does then all is well and you can authenticate the submitted details. If it doesn't then you can display your 'cookies required' message.
As it required at least to requests to your site to make this check it means you cannot show a message as soon as they request the login page as you cannot assume a user hasn't come to your site directly via this page.

Andy Rose