[racket] (no subject)

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Jun 28 11:16:34 EDT 2010

The code you pasted is not a full program so I cannot test it. In
particular, I don't see the definition of editor-cookie, so I'm not
sure what it does.

The example program from the documentation [1]:

#lang web-server/insta
(define (start req)
  (define cookies (request-cookies req))
  (define id-cookie
    (findf (lambda (c)
             (string=? "id" (client-cookie-name c)))
           cookies))
  (if id-cookie
      (hello (client-cookie-value id-cookie))
      (redirect-to
       (url->string (request-uri req))
       see-other
       #:headers
       (list
        (cookie->header (make-cookie "id" "joseph"))))))

(define (hello who)
  `(html (head (title "Hello!"))
         (body
          (h1 "Hello "
              ,who))))

works for me in multiple browsers.

The only thing different I see is that you are using 'first' while I
am using 'findf'.

Jay

1. http://pre.plt-scheme.org/docs/html/web-server/http.html#(part._cookie-parse)

On Sun, Jun 27, 2010 at 2:02 PM, Sayed <yayo23 at gmail.com> wrote:
> Hello, I am currently working on a website powered by racket and I am at a
> stage where I am
> trying to establish an authenticated presence on the website. The way I
> envision doing so is
> with an html form, comparing the inputting values (essentially username and
> password) against
> what I have in a mysql db- this part has already been established.
>
> The next step is where I am running into a snag- I am trying to issue a
> cookie to any authenticated
> users and then redirect to the 'authenticated area' of the website. Then all
> functions associated with this
> area will check for the valid cookie before rendering, and if it is not
> present then redirect to the login page.
> The trouble is that for some reason the cookie is not showing up after the
> redirect. Here is the relevant code.
>
> Esentially what is happening is 'cl-cookie' takes the value of empty.
>
> http://paste.lisp.org/display/111917
>
>
> Any help would be appreciated, thanks.
>
> - sayed
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.