Cookie Detection Question

Results 1 to 2 of 2

Thread: Cookie Detection Question

  1. #1
    Matt G. Guest

    Default Cookie Detection Question

    *<BR>Hello there --<BR><BR>At the first page of my website I detect if the browser is cookie-enabled (See the code below if you want). If it isn&#039t a suitable message is displayed. If it is, then I start adding values to the cookie. What I want to know is this:<BR><BR>Is it possible for me to check to see if cookies are possible WITHOUT having to call another page? That is, currently I try to write the cookie on the initial page. Then I Response.Redirect to a page that checks to see if the cookie was written successfully. According to my tests, I CANNOT write and then check to see if a write occurred successfully on the same page.<BR><BR>1) Am I right about needing two pages to do this?<BR>2) If so, could someone explain why? <BR><BR>Thanks,<BR><BR>Respectfully Yours,<BR><BR>Matt G. <BR><BR>------ This subroutine is from the first page ------<BR><BR>&#039---------------------------------------------------------------<BR>&#039 Set Cookies<BR>&#039---------------------------------------------------------------<BR>Sub SetCookies()<BR> Response.Cookies("ClientID").Expires = "December 31, 2001"<BR> Response.Cookies("CookiesCapable") = "Yes"<BR>End Sub<BR><BR><BR>------ This subroutine is from the 2nd page ------<BR><BR>&#039---------------------------------------------------------------<BR>&#039 View Cookies through ASP<BR>&#039---------------------------------------------------------------<BR>Sub ViewCookies()<BR> If Request.Cookies("CookiesCapable") = "" Then<BR> Response.Write("Your browser cannot currently handle cookies!")<BR> Else<BR> Response.Write("CookiesCapable = &#060;B&#062;" & Request.Cookies("CookiesCapable") & "&#060;/B&#062; at " & Time())<BR> End If<BR>End Sub<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Cookie Detection Question

    I use JavaScript to detect cookies. Our site uses session variables so IIS is writing out a session cookie. I detect<BR>that cookie in in one page and do not write out a cookie.<BR>Note that IE5 allows user to disable either session or local<BR>cookies. <BR><BR>//IIS writes out a cookie with string "ASPSESSIONID" when site is hit if per session cookie enabled.<BR>//SiteServer writes out "SITESERVER" to same cookie if local stored cookies enabled. Both required.<BR>var strCookie = document.cookie; <BR>if(strCookie.length&#062;0)<BR> {blnCookie = (strCookie.indexOf("ASPSESSIONID")&#062; -1) && (strCookie.indexOf("SITESERVER")&#062; -1) }<BR>else<BR> {blnCookie = false;}

Posting Permissions

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