I am using the jquery from https://github.com/carhartl/jquery-cookie. I am using the cookies for very first time. If I set the query by:
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
This creates the query but do not retain after the browser is closed. I dont have idea how to do that.
Secondly, every time I refresh the page it over writes the cookies as I dont need like this, I need to have check whether I am t开发者_运维技巧he first visitor or no. If no get the cookied or else set the cookie.
You need to add a condition to see if a cookie already exists so that it doesn't get replaced. Try:
<script type="text/javascript">
$(function () {
if($.cookie("new_visitor") != "true") {
$.cookie("new_visitor", "true", { expires: 21, path: '/' });
$.jGrowl("Hello Joe Public<br/><br/><a href='#'>Click me</a>", {sticky: true});
}
});
</script>
精彩评论