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 | |
| parent | b538b3c6519bd5dc026c488bbeab683695abc320 (diff) | |
| download | zorglub-629910e036e5a590903cce9a6461ee660b1dfd6a.zip zorglub-629910e036e5a590903cce9a6461ee660b1dfd6a.tar.gz  | |
example: update session part
Diffstat (limited to 'example')
| -rw-r--r-- | example/sample.ru | 35 | ||||
| -rw-r--r-- | example/view/url3/index.haml | 5 | 
2 files changed, 22 insertions, 18 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  # diff --git a/example/view/url3/index.haml b/example/view/url3/index.haml index ff91a0b..789cf16 100644 --- a/example/view/url3/index.haml +++ b/example/view/url3/index.haml @@ -1,6 +1,9 @@  %h2=@title  %p=Time.now.strftime '%H:%M:%S' -%p=@data +%p="SID : #{@sid}" +%p="Session data : #{@data}"  %a{:href=>Node3.r}="reload"  %br +%a{:href=>Node3.r('reset')}="reset session" +%br  %a{:href=>Node0.r}="back"  | 
