Cookie Check for Browser

Cookie Check for Browser

  
I have an app which requires the use of cookies. I obviously want to check on session start, or at the first web page of my app if the users browser will accept cookies. I created a start page, with a preperation which references the HTTPRequestHandler Set/Get cookies. I set a test cookie with a specific value, then immediately do a get cookie to compare the value received with what was set. If the values match, then I immediately goto a new destination screen from the preparation of the cookiecheck page. If the values are not the same, I assume the user has disabled cookies and I display the contents of the cookiecheck page.

My issue is that in my testing the setcookie and getcookie seem to work fine (I always get the value I set back) even if the users browser has cookies disabled. Is there some sort of memory sharing going on here?

Does this seem like a valid method to check for cookies in OS, or can anyone recommend another way?

Thanks

Ken
Hi Ken,

Are you doing the Set and GetCookie on the same flow? You'll need to trigger a postback to tell if the cookie was accepted by the browser or not.

You may create the cookie in one screen (A), and then redirect the browser to another screen (B), where you check for the existence of the cookie.

For redirecting the browser from screen A to screen B you may use javascript or a meta refresh, using a non-escaped expression like this:

"<meta http-equiv=""refresh"" content=""0;url=" + URL_Of_Screen_B + """>"

Other ways include checking for the cookie entirely with javascript, as this method:
http://www.4guysfromrolla.com/webtech/082400-1.shtml

Cheers,
Paulo Ramos
Thanks. Yes, I was doing the check in a single flow. I made the redirect as you suggest. At run time the page "continuously refreshes".

I stopped the refresh and viewed the web page I was redirecting to. The redirect URL looks correct. I pasted that URL in the browser and the page loaded and checked the cookie as expected.

I have extracted this process and attached the simple eSpace showing the cookie check process. Any thoughts?
Hi Ken,

I checked your eSpace, and found that the meta tag was broken - the URL parameter was not being included in the content attribute. Please try this:

"<meta http-equiv=""refresh"" content=""0;url="+BaseURL +"/browsercheck.aspx"+URLParms+""">"

Cheers,
Paulo Ramos
Hello,

I'm trying to use the SetCookie. Isn't suppose this action SAVE a Cookie text file in my disk, in the Internet Explorer cookie folder "Cookies"?

Something like: PC@localhost[1].txt

Is that anyway that I can do that?

I'm using my own Users Entity, so I would like to create a Persistent_Login entity to simulate the "Remember me" feature...

Thanks
Hi Victor,

Are you having troubles using SetCookie? Maybe you're using a session (non-persistent) cookie. Note the CookieExpirationSpan parameter description:
"Cookie expiration span in minutes. If lower than or equal to zero the cookie will only be valid during current session." (v4.0).

You should specify a value here, otherwise it will create a session cookie (that probably does not appear in "Cookies" folder).

A good tool for checking cookies is the "View Cookies" Firefox add-on, available here:
https://addons.mozilla.org/en-US/firefox/addon/315
Along with other information, you will able to see if the cookie is persistent (has an expire date) or session-only.

Cheers,
Paulo Ramos