Browser widget cookies?

hh hh at
Wed Aug 28 05:57:08 EDT 2019

> Geoff C. wrote:
> If I set the url for the browser widget to a url, and the
> server sets a cookie, can I read/modify/delete that cookie?

Cookie structure (itemdel is ";").
  item 1: A "name = value" pair containing the actual data,
  item 2: An expiry date after which it is no longer valid,
  item 3: The domain and path of the server.

   1. set the javascriptHandlers of widget "browser" to "JS"
   2. In the widget's script (or above it) write
   on JS x
     replace ";" with ";" & cr in x -- it make more readable
     put x into fld "Cookies"
   end JS

Then, on mouseUp:

-- read (you get only 'name=value' pairs, not expires nor path)
do    "liveCode.JS(document.cookie)" in widget "browser"

-- create/modify (path is usually the current page)
do    "document.cookie = 'username=Geoff Canyon;" & \
      "expires=Mon, 23 Dec 2019 22:30:00 UTC;" & \
      "path=/;' " in widget "browser"

-- delete (set it with an expiry date before today)
do    "document.cookie = 'username=Geoff Canyon;" & \
      "expires=Sat, 23 Dec 2000 22:30:00 UTC;" & \
      "path=/;' " in widget "browser"

More information about the use-livecode mailing list