diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-04 14:24:24 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-04 14:24:24 +0100 |
commit | 629910e036e5a590903cce9a6461ee660b1dfd6a (patch) | |
tree | f14cbe456f053b01f33aacc5704deba4b818d5e4 /example/sample.ru | |
parent | b538b3c6519bd5dc026c488bbeab683695abc320 (diff) | |
download | zorglub-629910e036e5a590903cce9a6461ee660b1dfd6a.zip zorglub-629910e036e5a590903cce9a6461ee660b1dfd6a.tar.gz |
example: update session part
Diffstat (limited to 'example/sample.ru')
-rw-r--r-- | example/sample.ru | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/example/sample.ru b/example/sample.ru index 063680f..45614f6 100644 --- a/example/sample.ru +++ b/example/sample.ru @@ -95,21 +95,22 @@ class Node3 < Zorglub::Node # def index *args @title = "Session tests" - if not session.exists? - @data = "NO SESSION" + t = Time.now + @sid = session.sid + if session[:now].nil? + session[:now] = t + @data = "#{t.strftime('%H:%M:%S')} FIRST" + elsif t-session[:now]>10 + session[:now] = t + @data = "#{t.strftime('%H:%M:%S')} UPDATE" else - t = Time.now - if session[:now].nil? - session[:now] = t - @data = "#{t.strftime('%H:%M:%S')} FIRST" - elsif t-session[:now]>5 - session[:now] = t - @data = "#{t.strftime('%H:%M:%S')} UPDATE" - else - @data = "#{session[:now].strftime('%H:%M:%S')} CURRENT" - end + @data = "#{session[:now].strftime('%H:%M:%S')} CURRENT" end end + def reset + session.destroy! + redirect :index + end # end # # @@ -145,11 +146,11 @@ puts APP.to_hash.inspect map '/' do use Rack::Lint use Rack::ShowExceptions - use Rack::Session::Cookie, :key=>Zorglub::Session.session_key, - :secret=>'my-secret-secret', - :path=>'/', - :http_only=>true, - :expire_after=>30 +# use Rack::Session::Cookie, :key=>Zorglub::Session.key, +# :secret=>'my-secret-secret', +# :path=>'/', +# :http_only=>true, +# :expire_after=>30 run APP end # |