Cookie trouble

Results 1 to 2 of 2

Thread: Cookie trouble

  1. #1
    Steven L Guest

    Default Cookie trouble

    I searched the archives and have found people might be having similar problems, but have found no solutions: <BR><BR>I&#039;m using a combination of ASP and Javascript cookies to: <BR>1) Make sure the user isn&#039;t using a cached page <BR>2) Verify the user has enabled his cookies <BR><BR>It works 99% of the time, but I&#039;ve gotten complaints from some people that they&#039;ve enabled cookies, and are still getting redirected to the Bad Cookie page. Any suggestions? Here&#039;s the code: <BR><BR>Response.Cookies("cookietest")="Yes" <BR>Response.Cookies("cookietest").expires=DateAdd ("n",10,Now) <BR>if not Request.Cookies("cookietest")="Yes" then <BR>Response.Redirect("badcookie.asp") <BR>end if <BR>%&#062; <BR>&#060;HTML&#062; <BR>&#060;HEAD&#062; <BR>&#060;!-- #include virtual="/files/jscookies.asp" --&#062; <BR>&#060;SCRIPT&#062; <BR>&#060;!-- Hide from older browsers <BR>if (getCookie("cookietest")!="Yes") <BR>this.document.location.href="/home/badcookie.asp"; <BR>// Stop hiding --&#062; <BR>&#060;/SCRIPT&#062; <BR><BR>JSCookies is this file that I downloaded: <BR><BR>&#060;SCRIPT&#062; <BR>&#060;!-- Hide from older browsers <BR><BR>// Original JavaScript code by Duncan Crombie: <BR>// Please acknowledge use of this code by including this header. <BR><BR> var bites = document.cookie.split("; "); // break cookie into array of bites <BR><BR> function getCookie(name) { // use: getCookie("name"); <BR> for (var i=0; i &#060; bites.length; i++) { <BR> nextbite = bites[i].split("="); // break into name and value <BR> if (nextbite[0] == name) // if name matches <BR> return unescape(nextbite[1]); // return value <BR> } <BR> return null; <BR> } <BR><BR> var today = new Date(); <BR> var expiry = new Date(today.getTime() + 10 * 1000); // plus 10 minutes <BR><BR> function setCookie(name, value) { // use: setCookie("name", value); <BR> if (value != null && value != "") <BR> document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString(); <BR> bites = document.cookie.split("; "); // update cookie bites <BR> } <BR><BR>// Stop hiding --&#062; <BR>&#060;/SCRIPT&#062; <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Cookie trouble

    try making sure the path of both cookies is set to &#039;/&#039;<BR><BR>j

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts