2 Replies Latest reply on Nov 26, 2014 8:09 AM by fxjeane

    How to read and write c

    fxjeane

      I am trying to store some information received when I login to a web service. However im having a hard time understanding how cookies are handled under CEP. Documentation says that cookies are stored at:

       

      /Users/<user>/Library/Logs/CSXS/cep_cookies

       

      but the file is not there.

       

      Im also using the CEP HTML Test extension to test the cookies. I see the sample works properly, meaning that it loads the cookie the next time the page is requested, however I don't see the cookie file in my file system. Can someone please shine light on where the cookie file is located?

      I can see under the cep_cache directory that there is a Cookies file under the folder of my extension, which seems to be a Sqlite file.  I have tried to use the example provided in CEP HTML Test extension but I just cant seem to read back the cookie I set.

       

      Here is the code

       

      function setCookie(cname,cvalue,exdays) {

          var d = new Date();

          d.setTime(d.getTime() + (exdays*24*60*60*1000));

          var expires = "expires=" + d.toGMTString();

          document.cookie += cname+"="+cvalue+"; "+expires;

      }

       

      function getCookie(cname) {

          var name = cname + "=";

          var ca = document.cookie.split(';');

          for(var i=0; i<ca.length; i++) {

              var c = ca[i];

              while (c.charAt(0)==' ') c = c.substring(1);

              if (c.indexOf(name) != -1) {

                  return c.substring(name.length, c.length);

              }

          }

          return "";

      }

       

       

      setCookie('FOO','BAR',7);

      console.log(getCookie('FOO'));

       

      Im running this on a local server using an unsigned extension (still in development). Please help. this is driving me mad!

        • 1. Re: How to read and write c
          fxjeane Level 1

          I also must mention that I did a test with the code in a chrome browser. When I use a webserver (apache) the cookies work, however when I use the file access file:/// the cookies fail. This leads me to believe that there is header information that is not available when using file access.

           

          When I run the extension under After Effects I see that the alert title reads file:///... as the location. Does this change when the extension is  signed? would that start including the necessary header information to make the cookies work?

          • 2. Re: How to read and write c
            fxjeane Level 1

            I ended up creating my own way of managing session data because I could not get the cookies to work with AJAX. Cheers!