![]() |
# 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 |
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

[ show source ]
# 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
![Permalink to Public Instance method: []](../../permalink.gif)
Get a session value
[ show source ]
# 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
![Permalink to Public Instance method: []=](../../permalink.gif)
Set a session value
[ show source ]
# 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

Times out the session immediately
[ show source ]
# 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

Create a new session variable with name key and value value
[ show source ]
# File lib/asp/session.rb, line 76 def add( key, val ) self[key]=val end

— Reserved for Ruby/ASP internal use —
[ show source ]
# 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

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 209 def clear( ) ## -> void end

Gets or sets the code page identifier for the current session. (Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 116 def codePage( ) ## -> int end

Gets a reference to the current session-state object.
[ show source ]
# File lib/asp/session.rb, line 121 def contents( ) ## -> System.Web.SessionState.HttpSessionState return self end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 214 def copyTo( lArray, iIndex ) ## -> void end

Gets the number of items in the session-state collection. (Not Implemented)
[ show source ]
# 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

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 219 def getEnumerator( ) ## -> System.Collections.IEnumerator end

true if the session is embedded in the URL; otherwise, false. (To be Implemented)
[ show source ]
# File lib/asp/session.rb, line 143 def isCookieless ## -> bool end

true if the session was created with the current request; otherwise, false.
[ show source ]
# File lib/asp/session.rb, line 148 def isNewSession( ) ## -> bool return @bIsNewSession end

true if the session is read-only; otherwise, false. (Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 155 def isReadOnly( ) ## -> bool end

true if access to the collection is synchronized (thread safe); otherwise, false. (Not Implemented - always true)
[ show source ]
# File lib/asp/session.rb, line 161 def isSynchronized( ) ## -> bool return true end

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

Gets a collection (Array) of the keys of all values stored in the session.
[ show source ]
# 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

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 187 def lcid( ) ## -> int end

Gets the current session-state mode. Always PStore
[ show source ]
# File lib/asp/session.rb, line 193 def mode( ) ## -> System.Web.SessionState.SessionStateMode return "PStore" end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 224 def remove( xKey ) ## -> void end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 229 def removeAll( ) ## -> void end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 234 def removeAt( iIndex ) ## -> void end

Returns the id for the current session
[ show source ]
# File lib/asp/session.rb, line 96 def sessionID( ) return @sessionID end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 199 def staticObjects( ) ## -> System.Web.HttpStaticObjectsCollection end

(Not Implemented)
[ show source ]
# File lib/asp/session.rb, line 204 def syncRoot( ) ## -> object end

Set (if min is not null) and return timeout for the user session
[ show source ]
# 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

Set timeout for the user session
[ show source ]
# File lib/asp/session.rb, line 91 def timeout=( min ) return timeout( min ) end