# Class: Asp::Session
[ "README", "lib/asp/server.rb", "lib/asp/application.rb", "lib/asp/request.rb", "lib/asp/response.rb", "lib/asp/session.rb", nil].each do
Asp.view_html
Asp::Session.view_html
Asp::Response.view_html
Asp::Application.view_html
Asp::Server.view_html
Asp::Request.view_html
Asp::Eval.view_html
end

Class Asp::Session < Object

(in files lib/asp/session.rb )

Copyright (C) 2003, 2004 Gregoire Lejeune <gregoire.lejeune@free.fr>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods

Public Class method: new( r, oAspError, aspHandler, id=nil )

# File lib/asp/session.rb, line 259
    def initialize( r, oAspError, aspHandler, id=nil )
      @oApacheRequest = r
      @oAspError = oAspError
      @oAspHandler = aspHandler
      @sessionID = nil
      @sessionDBFile = nil
      @sessionDB = nil
      @timeout = Time::now+(60*Asp::Common::sessionTimeout)
      @bSendCookie = true

      if id.nil? == false
        @sessionID = id
      else
        getSessionIDFromCookie
      end
      @bIsNewSession = @sessionID.nil?

      openSessionDB
    end

Public Instance method: [](key)

Get a session value

# File lib/asp/session.rb, line 26
    def [](key)
      rcod = nil
    
      if @sessionDB.nil? == true
        @sessionID = newSessionID
        openSessionDB

        if @oAspHandler.public_methods.member?( "session_OnStart" ) == true
          @oAspHandler.session_OnStart
        end
      end
    
      @sessionDB.transaction {
        begin
          rcod = @sessionDB[key]
        rescue PStore::Error
          rcod = nil
        end
      }

      return rcod
    end

Public Instance method: []=(key, val)

Set a session value

# File lib/asp/session.rb, line 50
    def []=(key, val)
      rcod = nil
    
      if @sessionDB.nil? == true
        @sessionID = newSessionID
        openSessionDB

        if @oAspHandler.public_methods.member?( "session_OnStart" ) == true
          @oAspHandler.session_OnStart
        end
      end
                        
      @sessionDB.transaction {
        @sessionDB[key] = val
        @sessionDB.commit
        begin
          rcod = @sessionDB[key]
        rescue PStore::Error
          rcod = nil
        end
      }
    
      return rcod
    end

Public Instance method: abandon( )

Times out the session immediately

# File lib/asp/session.rb, line 101
    def abandon( )
      if @sessionID.nil? == false and @sessionDB.nil? == false
        @sessionID = nil
        @sessionDB = nil
        File::rm_f( @sessionDBFile )
        @bSendCookie = true
        
        if @oAspHandler.public_methods.member?( "session_OnEnd" ) == true
          @oAspHandler.session_OnEnd
        end
      end
    end

Public Instance method: add( key, val )

Create a new session variable with name key and value value

# File lib/asp/session.rb, line 76
    def add( key, val )
      self[key]=val
    end

Public Instance method: addSessionCookieHeader( )

— Reserved for Ruby/ASP internal use —

# File lib/asp/session.rb, line 239
    def addSessionCookieHeader( )
      
      #if @sessionID.nil? == false and @bSendCookie == true
      if @bSendCookie == true
        if @sessionID.nil? == false
          expires = "; expires="+String( @timeout )
          cookie = Asp::Common::sessionID+"=id="+@sessionID+"&exp="+Asp::Common::url_encode( String( @timeout ) )+expires+"; path=/"
        else
          @timeout = Time::at( 0 )
          expires = "; expires="+String( @timeout )
          cookie = Asp::Common::sessionID+"=id=00&exp="+Asp::Common::url_encode( String( @timeout ) )+expires+"; path=/"
        end
        return cookie
      end

      return nil
    end

Public Instance method: clear( )

(Not Implemented)

# File lib/asp/session.rb, line 209
    def clear( )
      ## -> void
    end

Public Instance method: codePage( )

Gets or sets the code page identifier for the current session. (Not Implemented)

# File lib/asp/session.rb, line 116
    def codePage( )
      ## -> int
    end

Public Instance method: contents( )

Gets a reference to the current session-state object.

# File lib/asp/session.rb, line 121
    def contents( )
      ## -> System.Web.SessionState.HttpSessionState
      return self
    end

Public Instance method: copyTo( lArray, iIndex )

(Not Implemented)

# File lib/asp/session.rb, line 214
    def copyTo( lArray, iIndex )
      ## -> void
    end

Public Instance method: count( )

Gets the number of items in the session-state collection. (Not Implemented)

# File lib/asp/session.rb, line 128
    def count( )
      ## -> int
      iCount = 0
      
      if @sessionDB.nil? == false
        @sessionDB.transaction do
          iCount = @sessionDB.roots.size
        end
      end
      
      return iCount
    end

Public Instance method: getEnumerator( )

(Not Implemented)

# File lib/asp/session.rb, line 219
    def getEnumerator( )
      ## -> System.Collections.IEnumerator
    end

Public Instance method: isCookieless()

true if the session is embedded in the URL; otherwise, false. (To be Implemented)

# File lib/asp/session.rb, line 143
    def isCookieless
      ## -> bool
    end

Public Instance method: isNewSession( )

true if the session was created with the current request; otherwise, false.

# File lib/asp/session.rb, line 148
    def isNewSession( )
      ## -> bool
      return @bIsNewSession
    end

Public Instance method: isReadOnly( )

true if the session is read-only; otherwise, false. (Not Implemented)

# File lib/asp/session.rb, line 155
    def isReadOnly( )
      ## -> bool
    end

Public Instance method: isSynchronized( )

true if access to the collection is synchronized (thread safe); otherwise, false. (Not Implemented - always true)

# File lib/asp/session.rb, line 161
    def isSynchronized( )
      ## -> bool
      return true
    end

Public Instance method: item( key )

Gets individual session values.

# File lib/asp/session.rb, line 167
    def item( key )
      ## -> object
      return self[key]
    end

Public Instance method: keys( )

Gets a collection (Array) of the keys of all values stored in the session.

# File lib/asp/session.rb, line 173
    def keys( )
      ## -> System.Collections.Specialized.NameObjectCollectionBase+KeysCollection
      lxKeys = []
      
      if @sessionDB.nil? == false
        @sessionDB.transaction do
          lxKeys = @sessionDB.roots
        end
      end
      
      return lxKeys
    end

Public Instance method: lcid( )

(Not Implemented)

# File lib/asp/session.rb, line 187
    def lcid( )
      ## -> int
    end

Public Instance method: mode( )

Gets the current session-state mode. Always PStore

# File lib/asp/session.rb, line 193
    def mode( )
      ## -> System.Web.SessionState.SessionStateMode
      return "PStore"
    end

Public Instance method: remove( xKey )

(Not Implemented)

# File lib/asp/session.rb, line 224
    def remove( xKey )
      ## -> void
    end

Public Instance method: removeAll( )

(Not Implemented)

# File lib/asp/session.rb, line 229
    def removeAll( )
      ## -> void
    end

Public Instance method: removeAt( iIndex )

(Not Implemented)

# File lib/asp/session.rb, line 234
    def removeAt( iIndex )
      ## -> void
    end

Public Instance method: sessionID( )

Returns the id for the current session

# File lib/asp/session.rb, line 96
    def sessionID( )
      return @sessionID
    end

Public Instance method: staticObjects( )

(Not Implemented)

# File lib/asp/session.rb, line 199
    def staticObjects( )
      ## -> System.Web.HttpStaticObjectsCollection
    end

Public Instance method: syncRoot( )

(Not Implemented)

# File lib/asp/session.rb, line 204
    def syncRoot( )
      ## -> object
    end

Public Instance method: timeout( min=nil )

Set (if min is not null) and return timeout for the user session

# File lib/asp/session.rb, line 81
    def timeout( min=nil )
      if min.nil? == false
        @bSendCookie = true
        @timeout = Time::now+(60*min)
      end

      return @timeout
    end

Public Instance method: timeout=( min )

Set timeout for the user session

# File lib/asp/session.rb, line 91
    def timeout=( min )
      return timeout( min )
    end