From e44528d5ff7fbb5d2698baf6443c145bcf98b309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 4 Jan 2012 14:18:34 +0100 Subject: session: update class variables, set cookie if none --- lib/zorglub/session.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/zorglub/session.rb b/lib/zorglub/session.rb index c6a050e..da2c3f0 100644 --- a/lib/zorglub/session.rb +++ b/lib/zorglub/session.rb @@ -39,10 +39,12 @@ module Zorglub # class Session # - @session_key = 'zorglub.sid' - @session_kls = Zorglub::SessionHash + @key = 'zorglub.sid' + @kls = Zorglub::SessionHash + @sid_length = 64 + # class << self - attr_accessor :session_key, :session_kls + attr_accessor :key, :kls, :sid_length end # def initialize req, resp @@ -53,9 +55,12 @@ module Zorglub # def setup! if Config.session_on - @instance = Session.session_kls.new @request.cookies[Session.session_key] - else - @instance = {} + cookie = @request.cookies[Session.key] + if cookie.nil? + cookie = generate_sid + @response.set_cookie Session.key, cookie + end + @instance = Session.kls.new cookie end end private :setup! -- cgit v1.1-2-g2b99