9 Replies Latest reply on Apr 23, 2015 2:28 AM by woz

    Web viewer cookie persistence


      I have a use case in that I would like for some web viewer data to survive a refresh of the web viewer. I thought setting a cookie via javascript would work. The cookie only seems to last until a refresh/reload of the web viewer.


      Does anyone know if this is possible or can suggest an alternative technique?

        • 1. Re: Web viewer cookie persistence

          The webviewer is not a web browser.   A alternative method may be sending the information to the clipboard with java script and then pasting back into FMP with the  paste script step. 

          • 2. Re: Web viewer cookie persistence

            you can set the parameter in the url when loading and set the value with the FMP url protocol to save it to filemaker

            • 3. Re: Web viewer cookie persistence

              If you are using a Mac then FMP URL is not a bad way to save the data back to FM as Jared states, but with a PC the amount of data is limited to what can be sent back.  Even FMEasySignature | An Open Source Signature Capture Solution for the FileMaker Platform and the other projects created by Tim Dietrich will not work correctly on a PC because of this limit. (The reason for the Mac only Statement on that page).   I made a version of the FMEasySignature  database to work with a PC and I had to  copy the data to the clipboard and then paste it into FM. 

              • 4. Re: Web viewer cookie persistence

                for Mac? Win? iOS?


                We do have Cookie functions in MBS Plugins for OS X.

                • 5. Re: Web viewer cookie persistence

                  The WebViewer does work with cookies and they persist beyond refreshing if you set an expiration date for the cookie some time in the future. Here is a javascript function I use for setting cookies that works great:


                      function setCookie(name,value,days) {

                        var expires;

                        if (days) {

                          var date = new Date();


                          expires = "; expires="+date.toGMTString();


                        else {

                          expires = "";


                        document.cookie = name + "=" + value + expires + "; path=/";



                  When you call the function set days to how many days you want the cookie to persist. Then I use these functions for reading the cookies:


                      function parseCookie(name, cookieString) {

                        var nameEQ = name + "=";

                        var ca = cookieString.split(';');

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

                          var c = ca[i];

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

                          if (c.indexOf(nameEQ) === 0) {

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



                        return null;




                      function getCookie(name) {

                        var cookies = document.cookie;

                        return parseCookie(name, cookies);



                  These are used in the SeedCode calendar "DayBack" and they work fine even if the WebViewer is refreshed.




                  Tanner Ellen
                  tel. (855) 733-3263
                  SeedCode: Start Making Software

                  1 of 1 people found this helpful
                  • 6. Re: Web viewer cookie persistence

                    Thanks I was aware of the WV not being a full browser. I thought/hoped it might use cookies though.

                    • 7. Re: Web viewer cookie persistence

                      Thanks, that's effectively what I did to solve it but others say a cookie should work. I may play some more.

                      • 8. Re: Web viewer cookie persistence

                        Thanks Christian. I did come across MBS cookie functions during my research but it needs to work on all platforms.

                        • 9. Re: Web viewer cookie persistence

                          Interesting. The code I used looked pretty similar to your example and I was specifying an expiry. I couldn't seem to get it to work, though the same HTML+javascript code worked fine in Safari/Mac and I could see my cookies being set. By coincidence my app is a calendar too. The refreshes on the web viewer were being triggered by a data update script called from the javascript. The day after my posting, I did solve the problem by returning the data with the update script and then passing to the WV. Not as nice a solution as a cookie but I may try again.