Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    store() function

    Cloud CMS (Pagebuilder, Blog, Shop, Newsletters, Code Editor)
    3
    6
    556
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Daniel Mulroy
      Daniel Mulroy last edited by

      Hello team!

      I know you have an API for accessing browser local storage, store()

      Do you have any documentation for how it works? I see it takes 3 parameters, but I'm not sure what they all do.

      Thanks!

      1 Reply Last reply Reply Quote 1
      • Wassim
        Wassim last edited by Wassim

        Hello Daniel,

        Sure, let me explain to you how store function works on AppDrag.
        First of all it is used to read and write to the local storage and to fallback on cookies if local storage isn't available on a device/browser.

        The prototype is : store(key, value, onlyCookie);

        To write to the local storage (with cookie fallback) :

        store("name", "John Doe");
        

        To get a value from the local storage (or cookie if it fell back) :

        store("name"); // returns "John Doe";
        

        You can force to use cookies only with the optional third parameter.

        To write a cookie :

        store("name", "John Doe", true);
        

        To Read a cookie (note that we use undefined because we want to get a value and don't want to write anything :

        store("name", undefined, true); // returns "John Doe";
        
        K 1 Reply Last reply Reply Quote 2
        • Daniel Mulroy
          Daniel Mulroy last edited by

          Brilliant, thank you!

          1 Reply Last reply Reply Quote 2
          • K
            Konrad Hylton @Wassim last edited by

            @wassim Hey Wassim, would you say that this is a better solution to using localStorage.getItem('name’) and localStorage.setItem('name’), in most instances? And would it work in as the source, when the source type is formula when enabling a cloud backend trigger?

            1 Reply Last reply Reply Quote 0
            • Wassim
              Wassim last edited by

              Hello, no I would recommand you to use store('name') as it's more safe. Yes it works as a source for CloudBackend triggers with the formula type!

              1 Reply Last reply Reply Quote 0
              • K
                Konrad Hylton last edited by

                Thanks Wassim

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post