Arc Forumnew | comments | leaders | submitlogin
1 point by lark 4292 days ago | link | parent

It seems I need something like this:

  (defop-raw some-fancy-url (str req)
    (w/stdout str
              (anon-login req)
              (prn)
              (some-fancy-url-handler req)))

  (def anon-login (req)
       (if (no (get-user req))
           (withs (user (makeid 14)
                        cookie (cook-user user))
                  (= (logins* user) req!ip)
                  (prcookie cookie)
                  (prn)
                  (save-table cookie->user* cookfile*)
                  (user->cookie* user)
                  )))

  (def some-fancy-url-handler (req)
    (pr "Hello World"))

  ;; And visit /some-fancy-url


2 points by thaddeus 4289 days ago | link

If its just a one off thing then you could just emit/print raw JavaScript outputting the document onload function to trigger the storing or updating of your cookie (you could also build arc wrapper functions too).

I.e Document.Onload -> Document.Cookie

-----

2 points by lark 4284 days ago | link

These two lines are not needed:

             (save-table cookie->user* cookfile*)
             (user->cookie* user)
And replace

  makeid
with

  rand-string

-----

1 point by akkartik 4284 days ago | link

Thanks a lot!

-----

1 point by akkartik 4292 days ago | link

Yeah that seems plausible. I guess I don't understand what you're asking.

Perhaps it'll help to tell us more about what you're building and what you're trying to do and why.

-----