;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: July 2003
;;;;
-;;;; $Id: sessions.lisp,v 1.4 2003/08/08 23:40:13 kevin Exp $
+;;;; $Id: sessions.lisp,v 1.5 2003/08/09 21:42:24 kevin Exp $
;;;;
;;;; This file and Wol are Copyright (c) 2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package #:wol)
-#||
-(awhen (and session-id (find-websession session-id ent))
- (setf (websession-from-req req) it)
- (setf (websession-method it) :url))
-||#
-
(defun find-websession (key ent)
(let ((sessions (sessions (session-master (entity-project ent)))))
(maphash
:key key
:lastref (get-universal-time)
:lifetime (lifetime (session-master (entity-project ent)))
- :method :try-cookie))
+ :method nil))
(hash (sessions (session-master (entity-project ent)))))
(when hash
(setf (gethash key hash) sess)
sess)))
-(defun compute-session (req ent)
+(defun compute-session (req ent url-session-id)
(when (is-session-enabled ent)
- (let ((key (cookie-session-key ent (request-cookies req)))
- (has-cookie-key nil)
- (has-url-key nil))
- (if key
- (setq has-cookie-key t)
- (when (setq key (url-session-key (request-raw-uri req)))
- (setq has-url-key t)))
- (let* ((found-session (when key (find-websession key ent)))
- (session (aif found-session it (make-websession req ent))))
- (setf (websession-from-req req) session)
- (when found-session
- (if has-cookie-key
- (setf (websession-method session) :cookies)
- (when has-url-key
- (setf (websession-method session) :url))))
- session))))
+ (let* ((cookie-session-id (cookie-session-key ent (request-cookies req)))
+ (session-id (or url-session-id cookie-session-id))
+ (found-session (when session-id
+ (find-websession session-id ent)))
+ (session (aif found-session
+ it
+ (make-websession req ent))))
+ (cond
+ (cookie-session-id
+ (setf (websession-method session) :cookies))
+ (url-session-id
+ (case (websession-method session)
+ (nil
+ (setf (websession-method session) :try-cookie))
+ (:try-cookie
+ (setf (websession-method session) :try-cookie-2))
+ (t
+ (setf (websession-method session) :url)))))
+ (setf (websession-from-req req) session))))
;;; Reap expired sessions