JavaScript/jQuery Only Gets Executed On First Visit, Cookie Prevents It From Executing Again
How can I make JavaScript (or jQuery) code only execute on the visitor's first visit and never again until a cookie expires or is removed? For example: $('#example').hide(); How ca
Solution 1:
try this tut: http://www.electrictoolbox.com/jquery-cookies/ set a cookie on first visit, read it out on any subsequent visit and do something like:
if($.cookie.isset() == true) {
// do something
}
Solution 2:
In order to do like this. you should use server scripting for additional help.
Eg. in PHP
<?php
if(isset($_SESSION['session_name'])){
?>
Your javascript or jquery code here
<?
}
?>
Post a Comment for "JavaScript/jQuery Only Gets Executed On First Visit, Cookie Prevents It From Executing Again"