Skip to main content
vincentd38710796
Participant
Aug 14, 2020 2:01 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    Inspiring
    Jan 27, 2021 9:48 AM UTC

    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

    Translate
    schroef
    Inspiring
    Nov 9, 2023 12:48 AM UTC

    How would we use csevent for that?

    Do you mean by using csinterface somehow?

    Translate
    schroef
    Inspiring
    Nov 9, 2023 4:00 PM UTC

    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.

     

    Translate