Results 1 to 2 of 2

Thread: Using JS To Do A Only Once Option

  1. #1
    Join Date
    May 2008
    Thanked 0 Times in 0 Posts

    Default Using JS To Do A Only Once Option

    I am trying to write some JS code that let users access a page only once and only once.

    For example

    • User comes to a page and then click a link to a pop-up
    • Pop-up has some information, then users close it
    • If users tries to click the link to the pop-up again
    • A message comes up that say "Sorry you've already accessed this once"

    I'm think I need to set a cookie on the users computer but I just can't get the code.

    Thank you.

  2. #2
    Join Date
    Mar 2005
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries


    Javascript cookies are unreliable (the user's browser may refuse them and/or in some cases delete or rewrite them). If this is 'mission critical'*, you would need to work something out on the server side (PHP, asp, or whatever is available on your host in the way of a server side language that supports server side cookies or a variable(s) that can act like cookies). If this isn't 'mission critical', a good explanation of javascript cookies and functions that simplify the use of javascript cookies is here:

    *An example of 'mission critical' would be where, if the user took control of the situation, they could do something that would harm you. Like if sales or information that must remain private are involved, etc.
    - John

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate


Posting Permissions

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