Hunchentoot sessions

Discussion of Common Lisp

Hunchentoot sessions

Postby pseudo-cat » Sun Sep 25, 2011 2:31 am

Hello, I have'nt problems with hunchentoot's session mechanism on this code:
Code: Select all
(let ((s (hunchentoot:start-session))
          (cookie (hunchentoot:cookie-out "hunchentoot-session")))
      (setf (hunchentoot:session-max-time s) 172800)
      (setf (hunchentoot:session-value 'user s) user)
      (setf (hunchentoot:session-value 'pass s) pass)

BUT if I'll adding this line:
Code: Select all
   
(let ((s (hunchentoot:start-session))
          (cookie (hunchentoot:cookie-out "hunchentoot-session")))
      (setf (hunchentoot:session-max-time s) 172800)
      (setf (hunchentoot:session-value 'user s) user)
      (setf (hunchentoot:session-value 'pass s) pass)
      (format cl-user::*std-out* "cookie: ~a" cookie)
      (when cookie
        (setf (hunchentoot:cookie-expires
             (hunchentoot:cookie-out "hunchentoot-session"))
         172800)
      

then cookies are unused. So get-parameters used instead
pseudo-cat
 
Posts: 6
Joined: Thu Sep 02, 2010 3:53 pm
Location: Russia

Re: Hunchentoot sessions

Postby Kompottkin » Mon Sep 26, 2011 12:30 pm

pseudo-cat wrote:
Code: Select all
        (setf (hunchentoot:cookie-expires
             (hunchentoot:cookie-out "hunchentoot-session"))
         172800)


You're setting the expiration date of the cookie to 172800, which is sometime on January 3rd in the year 1900. Try something like (+ (get-universal-time) 172800) instead.
User avatar
Kompottkin
 
Posts: 94
Joined: Mon Jul 21, 2008 7:26 am
Location: München, Germany

Re: Hunchentoot sessions

Postby pseudo-cat » Wed Sep 28, 2011 1:38 pm

Kompottkin wrote:
pseudo-cat wrote:
Code: Select all
        (setf (hunchentoot:cookie-expires
             (hunchentoot:cookie-out "hunchentoot-session"))
         172800)


You're setting the expiration date of the cookie to 172800, which is sometime on January 3rd in the year 1900. Try something like (+ (get-universal-time) 172800) instead.

Exactly, thanks)
pseudo-cat
 
Posts: 6
Joined: Thu Sep 02, 2010 3:53 pm
Location: Russia


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 4 guests