SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Philip Toews's Avatar
    Join Date
    Dec 2001
    Kuala Belait, Brunei
    0 Post(s)
    0 Thread(s)

    help with a javascript & cookie script

    Hi folks,

    I know NOTHING about javascript but wish to implement a pop-up for all first time site visitors and then every three months or so. Digging around sitepoint I found this script

    How do I adjust the expiry of the cookie...I can see the numbers on line 48 but I don't really understand them...basically I want the cookie to show up every three months or so...

    Later I'll change it by setting a cookie with PHP that only shows the pop-up if a visitor is not subscribed to the newsletter...but that's for another day...

    Last edited by Philip Toews; Jul 15, 2002 at 14:02.
    Philip Toews Professional esl Educator and ASP.NET wannabe

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Dallas, TX
    0 Post(s)
    0 Thread(s)
    Well, the line you need to look at is here
    expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
    Basically, getTime() (when used on a valid Date object) returns the current time in milliseconds. The calculation used on the right adds 1 year in milliseconds. So... to add only 3 months to current time for expiration, change it like this:
    expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 91));
    I chose 91 days to represent 3 months.

    Hope this helps
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev


Posting Permissions

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