From: patrick-may@... (Patrick May) Date: 2001-11-29T08:53:39+09:00 Subject: [ruby-talk:26848] Session / CGI suggestion I think I have a nice way of combining the functionality of CGI and CGI::Session. I also think there is value to combining the two, since CGI::Session is always used with an instance of CGI. In fact, I find the separation of CGI and CGI::Session more frustrating than any other aspect of CGI's design. SessionCGI is used just like a CGI, except you can pass in session parameters in the constructor and aSessionCGI.out yields a session object. The session is automatically updated at the end of the out method. Also, to me it looks like aSessionCGI can be used instead of aCGI without breaking any existing code. Does this seem like a cleaner way of using sessions? Am I rehashing part of a discussion that happened along time ago in a galaxy far, far away? ~ Patrick May # Current usage of CGI and CGI::Session: cgi = CGI.new("html4") session = CGI::Session.new(cgi, "session_key" => "session-id", "prefix" => "web-session.") cgi.out { # write out response using the session } session.update # Example Usage of SessionCGI: cgi = SessionCGI.new("html4", "session_key" => "session-id", "prefix" => "web-session.") cgi.out { |session| # write out response using the session } # Here's the code for SessionCGI: require "cgi" require "cgi/session" class SessionCGI < CGI def initialize( type="query", session_options={}) @session_options = session_options super(type) end def out(options = "text/html") session = CGI::Session.new( self, @session_options ) super( options ) { yield session } session.update end end