[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with :cookies-setattr!
From: |
Nala Ginrut |
Subject: |
Re: Problems with :cookies-setattr! |
Date: |
Sat, 13 Feb 2021 04:59:20 +0800 |
User-agent: |
mu4e 1.4.15; emacs 27.1 |
Well, I think this is the last issue before I release 0.5.
You should link the client sent cookie with :cookies-set! to a generated
cookie in #:cookies, so that you can control it, for example:
-----------------cut---------------------
(get "/set"
#:cookies '(names a)
(lambda (rc)
(:cookies-set! rc 'a "a" 123)
;; Don't forget the path should be the same, otherwise the modified
;; cookie will not affect.
(:cookies-setattr! rc 'a #:path "/test")
"done"))
(get "/test"
#:cookies '(names a)
(lambda (rc)
;; link with :cookies-set!
(:cookies-set! rc 'a "a" (:cookies-value rc "a"))
(:cookies-setattr! rc 'a #:expires 21600 #:secure #t)
"yes"))
------------------end----------------------
Best regards.
Mortimer Cladwell writes:
> Hi,
>
> Using the following controller I can set a cookie "prjid"
>
> ----BEGIN----------------------------------------------
> (plateset-define cset
> (options #:cookies '(names prjid sid))
> (lambda (rc)
> (let* ((result "sometext")
> (dummy (:cookies-set! rc 'prjid "prjid" result))
> (cookies (rc-cookie rc)))
> (view-render "test" (the-environment)))))
> ----END------------------------------------------------
>
> In the Firefox console I see:
>
> Name: prjid
> Value: sometext
> Domain: 127.0.0.1
> Path: /plateset
> Expires: Thu, 28 Jan 2021 15:25:19 GMT (this is one hour in the future)
> Size: 13
> HttpOnly: true
> Secure: false
> SameSite: none
>
> I want to modify the Expires to 6 hours (21600 sec) into the future
>
> ----BEGIN----------------------------------------------
> (plateset-define update
> (options #:cookies '(names prjid sid))
> (lambda (rc)
> (let* (
> (result (:cookies-setattr! rc 'prjid #:expires 21600 #:domain #f #:path
> #f #:secure #f #:http-only #f))
> (cookies (rc-cookie rc))
> (view-render "test" (the-environment)))))
> ----END------------------------------------------------
>
>
> Doesn't work. I have tried matching some/all of the other parameters to
> the existing cookie without effect. I can:
>
> (:cookies-setattr! rc 'prjid #:expires 21600 #:domain #f #:path "/junk"
> #:secure #f #:http-only #f)
>
> To get:
>
> Name: <blank>
> Value: <blank>
> Domain: 127.0.0.1
> Path: /junk
> Expires: Thu, 28 Jan 2021 20:39:24 GMT (6 hours into the future)
> Size: 0
> HttpOnly: true
> Secure: false
> SameSite: none
>
> So here the path and expires are correct but no name - i.e. does not affect
> the existing cookie but creates a new blank cookie.
>
> I assume :cookies-setattr! will only work on existing cookies, is that
> correct?
> In addition to changing the expiration time I would like to change the path
> from "/plateset" to "/" so the cookie is available sitewide - should that
> be possible?
> When setting a parameter to #f e.g. #:secure #f - does that mean change
> that parameter to #f or "don't modify that parameter"? Seems like all
> parameters are required.
> What am I doing wrong?
> Thanks
> Mortimer
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Problems with :cookies-setattr!,
Nala Ginrut <=