Easy cookie problem... I need help

Results 1 to 5 of 5

Thread: Easy cookie problem... I need help

  1. #1
    Join Date
    Dec 1969
    Posts
    161

    Default Easy cookie problem... I need help

    I want to set a cookie that expires in 40 hours. If the person tries to revisit that page again before 40 hours, he gets a message that says "You cannot do this now. You must wait xx hours more."<BR><BR>If you know how, I would appreciate your assistance!!!<BR><BR>Edward

  2. #2
    Druggie Guest

    Default RE: Easy cookie problem... I need help

    Hmmm if you want to deny them access to your page before 40 hours, then a cookie is not a good way to go about doing it. After all the person could just delete the cookie and they would have full access to your site again. <BR><BR>If your users have to login/logout of your site you might want to use a database to store their last access time information and use ASP to deny them access by redirecting them somewhere if they have accessed it before 40 hours<BR><BR>If you still want to use the cookie route, when creating the cookie just specify the time interval...<BR>Response.Cookies(cookieName).Expire s = Now() + 7<BR><BR>Look at this page for more cookie information:<BR>http://www.4guysfromrolla.com/webtech/110299-1.shtml<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    161

    Default Thanks for the advice, but a cookie is what I want

    Yes, I have thought about the possibility that someone can delete the cookie, but I prefer it anyway. A database is not secure either.... accounts are free and the user can easily create a new account and have access to that page again. One more question.... in your example, you use <BR>response.cookie(cookiename).expires = now() + 7<BR>what are the exact parameters for hours, days, months, years?<BR>What if you want it to expire in 7 hours? Or 8 days?<BR><BR>Thanks,<BR><BR>Edward

  4. #4
    Join Date
    Dec 1969
    Posts
    915

    Default RE: Thanks for the advice, but a cookie is what I

    Try Now() + 1.666667.<BR><BR>This will be equal to 40 hours.<BR><BR>HTH<BR><BR>Jerry<BR><BR>


  5. #5
    Join Date
    Dec 1969
    Posts
    161

    Default Still need more advice.....

    Ok, that is kewl... I also found another post that shows a way to expire the cookie like so:<BR>Response.cookies("cookieName").expires = dateAdd("h", 40, Now())<BR><BR>But, I have another question.... How do I report to the browser something like.... "Cookie expires in 3 hrs, 20 minutes" ???<BR>which I will of course change the text to: "You do not have access to this page for another 3 hrs, 20 minutes."<BR><BR>Thanks,<BR><BR>Edward

Posting Permissions

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