diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-04 14:18:34 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-04 14:18:34 +0100 |
commit | e44528d5ff7fbb5d2698baf6443c145bcf98b309 (patch) | |
tree | 1c7b4a3e49abbe338f11d2236a98b329d82fa89f | |
parent | 2d92b642d6e34134418045dd5a4980820b5e43d2 (diff) | |
download | zorglub-e44528d5ff7fbb5d2698baf6443c145bcf98b309.zip zorglub-e44528d5ff7fbb5d2698baf6443c145bcf98b309.tar.gz |
session: update class variables, set cookie if none
-rw-r--r-- | lib/zorglub/session.rb | 17 |
1 files 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! |