NetTalk Central

Author Topic: Check if cookies are disabled  (Read 4203 times)

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Check if cookies are disabled
« on: September 28, 2009, 09:29:30 AM »
Hi,

is there any way for me to check if the cookies are disabled on client browser so I can give appropriate msg? Can it be done through NetTalk server code or it has to be done with some javascript on the page itself?

thanks,
Alex

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Check if cookies are disabled
« Reply #1 on: September 28, 2009, 09:57:34 AM »
What I would do is set the cookie, then try to read it. If you can't get the value back, then give a message, or whatever you want to do, indicating the client should turn on cookies.
Mike Grigsby
Credify Systems
Central Oregon, USA

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Check if cookies are disabled
« Reply #2 on: September 28, 2009, 11:38:27 AM »
Hi Mike,

that is a great idea. I may use it as a workaround if there is no built in option.

thanks,
Alex

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Check if cookies are disabled
« Reply #3 on: September 28, 2009, 12:36:11 PM »
To implement the idea, you might take a look at the Timer example included with NetTalk. I think you can probably do it pretty easily with that concept. I've been using it a lot.
Mike Grigsby
Credify Systems
Central Oregon, USA

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Check if cookies are disabled
« Reply #4 on: September 28, 2009, 11:16:47 PM »
Many thanks one more time Mike.

best regards,
Alex

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Check if cookies are disabled
« Reply #5 on: September 29, 2009, 10:35:34 PM »
The set cookie-and-read-it-back approach is by far the best one since it explicitly only uses the feature you are trying to test. If you used JavaScript to do it, and JS was disabled, then you might return a false error that cookies were disabled.

Of course dynamic NT pages depend on both cookies and JavaScript to work - but it's probably better if you test for both, and error on the _correct_ one.

I'm not so sure about using a timer - I'm allergic to timers most of the time.

Cheers
Bruce

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Check if cookies are disabled
« Reply #6 on: September 29, 2009, 10:58:50 PM »
hi Bruce,

what would be the best place to test the cookies, index page? And which embed would you recommend for this? I was trying to use SetCookie and GetValue but it always return blank regardless of the state of cookies in a browser (enabled/disabled).

thanks,
Alex

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Check if cookies are disabled
« Reply #7 on: September 30, 2009, 12:04:17 AM »
Bruce: Then you shouldn't have put the timer in there in the first place!<g> You'd be proud of me for getting a working progress bar in my app. Part of the screen is attached. It looks and works just like a Windows progress bar.

[attachment deleted by admin]
Mike Grigsby
Credify Systems
Central Oregon, USA

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Check if cookies are disabled
« Reply #8 on: September 30, 2009, 07:07:11 AM »
It's slightly more complex Alex because you need to get a _second_ request from the browser. And then you need to decide on how to present the error to the user.

Oh and no, I don't think you can tie it specifically to the index page because the user could come into the site at any stage.

I'll see if I can build detection for cookies, and indeed JavaScript, directly into NetTalk 5 to make it easier for you.

cheers
Bruce

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Check if cookies are disabled
« Reply #9 on: September 30, 2009, 07:22:31 AM »
Many thanks Bruce. I'm looking forward to version 5

best regards,
Alex