title: Angular JS - set $cookies domain wide failed
body: <p>I've been having troubles with setting cookies in my angularjs app. The situation is I want to set a cookies that is available site-wide, but I have no idea how to set all the params for the cookies using angular js default $cookies object.</p>
  
  <p>For example, normally in Javascript I would write this</p>
  
  <pre><code>var exp = new Date();
  exp.setTime(exp.getTime()+(24*60*60*1000)); // expires after a day
  document.cookie = "myCookies=yes;expires="+exp.toGMTString()+ ";domain=.example.com;path=/";
  </code></pre>
  
  <p>But as DOM object can't be loaded into my app easily, so I have to use $cookies (angular-cookies.js). The new code is:</p>
  
  <pre><code>angular.module('MyApp')
      .controller('MyCtrl', function ($scope, $filter, Slug,PUBLIC_ROUTES, $cookies) {
          var myCookies = $cookies['mycookies'];
          if (typeof myCookies == 'undefined' || typeof myCookies == undefined) {
              $cookies['mycookies'] = "yes";
          }
      });
  </code></pre>
  
  <p>But there's no way I can set the expiry date, path and domain as those are not available for $cookies.</p>
  
  <p>What should I do?</p>