Results 1 to 4 of 4

Thread: cookie not working - help needed!

  1. #1

    Thread Starter
    Member shamloo's Avatar
    Join Date
    Oct 2000
    Location
    Stockholm, Sweden
    Posts
    32

    Unhappy cookie not working - help needed!

    I need help with the script below.
    If the cookie is set, a message should say so. If not, a message will say so and then set the cookie and it's value.

    for some reason this does NOT work:
    Code:
    <% Option Explicit
    Response.Buffer = true
    
    Dim expDate, aspPoll
    
    aspPoll = "aspPoll"
    expDate = "2001-05-09 21:42" ' for this version this is static, it will be dynamic in the near future
    
    Response.write("------------------------<BR>")
    Response.write("ExpireDate: "& expDate &"<BR>")
    Response.write("TodayDate: "& now)
    Response.write("<BR>------------------------<BR><BR>")
    
    Response.write(Request.Cookies(aspPoll) &"<BR><BR><BR><BR><BR><BR>")
    
    IF (Request.Cookies(aspPoll) <> "") THEN
    	Response.write("the cookie is set and running!<BR>"&_
    	"Cookie Value: "& Request.Cookies(aspPoll))
    ELSEIF (Request.Cookies(aspPoll)="") THEN
    	Response.write("This cookie is not set yet...<BR>")
    	Response.write("<B>&nbsp;&nbsp;Creating cookie....</B><BR>")
    	
    	Response.Cookies(aspPoll).Expires = CDate(expDate)
    	Response.Cookies(aspPoll).Domain = ".Caffeine"
    	Response.Cookies(aspPoll).Path = "/"
    	Response.Cookies(aspPoll) = "someText"
    	Response.write("reload the page and this cookie will be set!!!<BR>")
    	Response.write("Cookie value: "& Request.Cookies(aspPoll) &"<BR><BR>")
    ELSE
    	Response.write("some other text here...")
    END IF
    %>
    <HTML>
    <HEAD>
    	<TITLE>Untitled</TITLE>
    </HEAD>
    
    <BODY BGCOLOR="#FFFFFF">
    
    </BODY>
    </HTML>

    I really appreciate any help since this is the last thing missing in my poll-system.

    thanks,
    David
    "There are no must's in life unless you provide for someone else than yourself"

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Are you sure that you set it correctly? Show us your setting code.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    New Member
    Join Date
    Apr 2001
    Location
    Hungary
    Posts
    8
    Try the following code.
    It works fine for me

    <% Option Explicit
    Response.Buffer = true

    Dim expDate, aspPoll

    aspPoll = "aspPoll"
    expDate = "2001-05-11 21:42" ' for this version this is static, it will be dynamic in the near future

    Response.write("------------------------<BR>")
    Response.write("ExpireDate: "& expDate &"<BR>")
    Response.write("TodayDate: "& now)
    Response.write("<BR>------------------------<BR><BR>")

    Response.write(Request.Cookies(aspPoll)("Main") &"<BR><BR><BR><BR><BR><BR>")

    IF (Request.Cookies(aspPoll)("Main") <> "") THEN
    Response.write("the cookie is set and running!<BR>"&_
    "Cookie Value: "& Request.Cookies(aspPoll)("Main"))

    ELSEIF (Request.Cookies(aspPoll)("Main")="") THEN
    Response.write("This cookie is not set yet...<BR>")
    Response.write("<B> Creating cookie....</B><BR>")

    Response.Cookies(aspPoll).Expires = CDate(expDate)
    Response.Cookies(aspPoll)("Main") = "sometext"
    Response.Cookies(aspPoll)("Domain") = ".Caffeine"
    Response.Cookies(aspPoll)("Path") = "/"
    Response.write("reload the page and this cookie will be set!!!<BR>")
    Response.write("Cookie value: "& Request.Cookies(aspPoll)("Main") &"<BR><BR>")
    Response.write("Domain value: "& Request.Cookies(aspPoll)("Domain") &"<BR><BR>")
    Response.write("Path value: "& Request.Cookies(aspPoll)("Path") &"<BR><BR>")

    ELSE
    Response.write("some other text here...")
    END IF
    %>
    <HTML>
    <HEAD>
    <TITLE>Untitled</TITLE>
    </HEAD>

    <BODY BGCOLOR="#FFFFFF">

    </BODY>
    </HTML>

  4. #4

    Thread Starter
    Member shamloo's Avatar
    Join Date
    Oct 2000
    Location
    Stockholm, Sweden
    Posts
    32
    thanks a lot mentor22!
    it works excellent now, but Im not sure where I did wrong.
    Is it that I did not use this syntax: Response.Cookies("cookieName")("subItem") ??
    if not, can you(or anybody) tell me where my code was incorrect ?

    I don't just want to have the code working, I also want to understand it

    thanks again,
    David
    "There are no must's in life unless you provide for someone else than yourself"

Posting Permissions

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



Click Here to Expand Forum to Full Width