Skip to main content
vincentd38710796
Participant
August 14, 2020
Question

How to share cookies between CEP panels of the same extension ?

  • August 14, 2020
  • 1 reply
  • 656 views

Hi,

Can anyone say me if it is possible to share cookies beetween panels ?

I want to log in a user in a panel and see I'm logged-in in an other one.

HTTP Domain and path are same between these two panels.

Panels are in the same InDesign extension bundle.

Thank you,

    This topic has been closed for replies.

    1 reply

    Inspiring
    January 27, 2021

    Yes. You can send the cookie as data on an CSEvent. Or you can write the cookie to a preferences file and read it from there in both panels

    schroef
    Inspiring
    November 9, 2023

    How would we use csevent for that?

    Do you mean by using csinterface somehow?

    schroef
    Inspiring
    November 9, 2023

    Okay i got it working through an article and lots of testing

     

    This is what i got I will simply the names by panel A and panel B also the JS files accordingly So in A.js i use this

     

    var event = new CSEvent();
    event.type = "com.sbaril.animdessin2.Panel.foo";
    event.scope = "APPLICATION";
    event.data = frameLength;
    csInterface.dispatchEvent(event);

     

    Then in B.js from the other panel. i add the addEventListener around the init stage. I first had it up in the script, but seems to have caused the issue.

     

    csInterface.addEventListener("com.sbaril.animdessin2.Panel.foo", function(e){
        // console.log("event: "+e.data);
        localStorage.setItem("frameLength", e.data)
    });

     

    So now when i  call an certain function in panel A, it send a specific number to panel B and now i can store the same number in the cookies of the other panel.