Setting cookie to entire site

  • Dan030981
  • Novice
  • Novice
  • User avatar
  • Posts: 23
  • Loc: Mass

Post 3+ Months Ago

So I'm trying to set this cookie to my entire site. Is this what it should look like?

Code: [ Select ]
<script type="text/javascript">
$(document).ready(function(){
  if($.cookie('jNotifyMSG') =='1'){
      } else {
        generateMessage();
      }
  });
    function generateMessage() {
        var mHeader = 'Friend request notification ';
        var mContent = '<div class="tweet">hello world</div> ';
        var mImage = 'notify/images/friend-request.png';
        var mOptions = {};
        // ttl
        mOptions.lifeTime = 5000;
        mOptions.close = function() {
    $.cookie('jNotifyMSG', '1','/', '', '');
  }
        $.jnotify(mHeader, mContent, mImage, mOptions);
    }
</script>
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.   if($.cookie('jNotifyMSG') =='1'){
  4.       } else {
  5.         generateMessage();
  6.       }
  7.   });
  8.     function generateMessage() {
  9.         var mHeader = 'Friend request notification ';
  10.         var mContent = '<div class="tweet">hello world</div> ';
  11.         var mImage = 'notify/images/friend-request.png';
  12.         var mOptions = {};
  13.         // ttl
  14.         mOptions.lifeTime = 5000;
  15.         mOptions.close = function() {
  16.     $.cookie('jNotifyMSG', '1','/', '', '');
  17.   }
  18.         $.jnotify(mHeader, mContent, mImage, mOptions);
  19.     }
  20. </script>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Hi Dan,

You are close, not sure if you have figured it out by now. For the $.cookie plugin you are using the parameters are:

cookie name, value, options

So for the last variable you want to make sure its enclosed in {} for all of the different options like this:

Code: [ Select ]
$.cookie('jNotifyMSG', '1', { path: '/', domain: '.yourdomain.com' });


So the path of / means all paths on the website have access to the cookie, and then for your domain if you simply put a dot in front of it then the cookie would work for that domain and all subdomains off of it such as www or anything else you have. If you only want it to work with a specific domain then put the entire domain there.

Hope that helps :)

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 132 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.