I'm trying to make a simple use of CGI::Session.

For example, if page1.rhtml is like this:
  1 <%
  2   require 'cgi'
  3   require 'cgi/session'
  4   require 'cgi/session/pstore'     # provides CGI::Session::PStore
  5
  6   cgi = CGI.new("html4")
  7
  8   session = CGI::Session.new(cgi,
  9       'database_manager' => CGI::Session::PStore,  # use PStore
 10       'session_key' => '_rb_sess_id',              # custom session
key
 11       'session_expires' => Time.now + 30 * 60,     # 30 minute
timeout
 12       'prefix' => 'pstore_sid_')                   # PStore option
 13   if cgi.has_key?('user_name') and cgi['user_name'] != ''
 14       # coerce to String: cgi[] returns the
 15       # string-like CGI::QueryExtension::Value
 16       session['user_name'] = cgi['user_name'].to_s
 17   elsif !session['user_name']
 18       session['user_name'] = "guest"
 19   end
 20   session.close
 21
 22 %>


How should page2.rhtml be like if I want to recover
session['user_name']?
-- 
Posted via http://www.ruby-forum.com/.