ok

Mini Shell

Direktori : /opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Session/Abstract/
Upload File :
Current File : //opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Session/Abstract/Persisted.html

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class Rack::Session::Abstract::Persisted - rack-2.2.8 Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
  var index_rel_prefix = "../../../";
</script>

<script src="../../../js/navigation.js" defer></script>
<script src="../../../js/search.js" defer></script>
<script src="../../../js/search_index.js" defer></script>
<script src="../../../js/searcher.js" defer></script>
<script src="../../../js/darkfish.js" defer></script>

<link href="../../../css/fonts.css" rel="stylesheet">
<link href="../../../css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link">Object
  
</div>

    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-i-call">#call</a>
    
    <li ><a href="#method-i-commit_session">#commit_session</a>
    
    <li ><a href="#method-i-commit_session-3F">#commit_session?</a>
    
    <li ><a href="#method-i-context">#context</a>
    
    <li ><a href="#method-i-cookie_value">#cookie_value</a>
    
    <li ><a href="#method-i-current_session_id">#current_session_id</a>
    
    <li ><a href="#method-i-delete_session">#delete_session</a>
    
    <li ><a href="#method-i-extract_session_id">#extract_session_id</a>
    
    <li ><a href="#method-i-find_session">#find_session</a>
    
    <li ><a href="#method-i-force_options-3F">#force_options?</a>
    
    <li ><a href="#method-i-forced_session_update-3F">#forced_session_update?</a>
    
    <li ><a href="#method-i-generate_sid">#generate_sid</a>
    
    <li ><a href="#method-i-initialize_sid">#initialize_sid</a>
    
    <li ><a href="#method-i-load_session">#load_session</a>
    
    <li ><a href="#method-i-loaded_session-3F">#loaded_session?</a>
    
    <li ><a href="#method-i-make_request">#make_request</a>
    
    <li ><a href="#method-i-prepare_session">#prepare_session</a>
    
    <li ><a href="#method-i-security_matches-3F">#security_matches?</a>
    
    <li ><a href="#method-i-session_class">#session_class</a>
    
    <li ><a href="#method-i-session_exists-3F">#session_exists?</a>
    
    <li ><a href="#method-i-set_cookie">#set_cookie</a>
    
    <li ><a href="#method-i-write_session">#write_session</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-Rack::Session::Abstract::Persisted">
  <h1 id="class-Rack::Session::Abstract::Persisted" class="class">
    class Rack::Session::Abstract::Persisted
  </h1>

  <section class="description">
    
<p><a href="ID.html"><code>ID</code></a> sets up a basic framework for implementing an id based sessioning service. Cookies sent to the client for maintaining sessions will only contain an id reference. Only <a href="Persisted.html#method-i-find_session"><code>find_session</code></a>, <a href="Persisted.html#method-i-write_session"><code>write_session</code></a> and <a href="Persisted.html#method-i-delete_session"><code>delete_session</code></a> are required to be overwritten.</p>

<p>All parameters are optional.</p>
<ul><li>
<p>:key determines the name of the cookie, by default it is &#39;rack.session&#39;</p>
</li><li>
<p>:path, :domain, :expire_after, :secure, and :httponly set the related cookie options as by <a href="../../Response/Helpers.html#method-i-set_cookie"><code>Rack::Response#set_cookie</code></a></p>
</li><li>
<p>:skip will not a set a cookie in the response nor update the session state</p>
</li><li>
<p>:defer will not set a cookie in the response but still update the session state if it is used with a backend</p>
</li><li>
<p>:renew (implementation dependent) will prompt the generation of a new session id, and migration of data to be referenced at the new id. If :defer is set, it will be overridden and the cookie will be set.</p>
</li><li>
<p>:sidbits sets the number of bits in length that a generated session id will be.</p>
</li></ul>

<p>These options can be set on a per request basis, at the location of <code>env['rack.session.options']</code>. Additionally the id of the session can be found within the options hash at the key :id. It is highly not recommended to change its value.</p>

<p>Is <a href="../../Utils/Context.html"><code>Rack::Utils::Context</code></a> compatible.</p>

<p>Not included by default; you must require &#39;rack/session/abstract/id&#39; to use.</p>

  </section>

  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    
    <section class="constants-list">
      <header>
        <h3>Constants</h3>
      </header>
      <dl>
      
        <dt id="DEFAULT_OPTIONS">DEFAULT_OPTIONS
        
        <dd>
        
      
      </dl>
    </section>
    

    
    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      
      <div id="attribute-i-default_options" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">default_options</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-key" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">key</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-sid_secure" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">sid_secure</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
    </section>
    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(app, options = {})</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 250</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span> = {})
  <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
  <span class="ruby-ivar">@default_options</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_OPTIONS</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-ivar">@key</span> = <span class="ruby-ivar">@default_options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:key</span>)
  <span class="ruby-ivar">@cookie_only</span> = <span class="ruby-ivar">@default_options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:cookie_only</span>)
  <span class="ruby-ivar">@same_site</span> = <span class="ruby-ivar">@default_options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:same_site</span>)
  <span class="ruby-identifier">initialize_sid</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-call" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">call</span><span
            class="method-args">(env)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="call-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 259</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">call</span>(<span class="ruby-identifier">env</span>)
  <span class="ruby-identifier">context</span>(<span class="ruby-identifier">env</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-commit_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">commit_session</span><span
            class="method-args">(req, res)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Acquires the session from the environment and the session id from the session options and passes them to <a href="Persisted.html#method-i-write_session"><code>write_session</code></a>. If successful and the :defer option is not true, a cookie will be added to the response with the session&#39;s id.</p>
          
          

          
          <div class="method-source-code" id="commit_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 373</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">commit_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">res</span>)
  <span class="ruby-identifier">session</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">get_header</span> <span class="ruby-constant">RACK_SESSION</span>
  <span class="ruby-identifier">options</span> = <span class="ruby-identifier">session</span>.<span class="ruby-identifier">options</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:drop</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:renew</span>]
    <span class="ruby-identifier">session_id</span> = <span class="ruby-identifier">delete_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">session</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">generate_sid</span>, <span class="ruby-identifier">options</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">session_id</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">commit_session?</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">options</span>)

  <span class="ruby-identifier">session</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:load!</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">loaded_session?</span>(<span class="ruby-identifier">session</span>)
  <span class="ruby-identifier">session_id</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">id</span>
  <span class="ruby-identifier">session_data</span> = <span class="ruby-identifier">session</span>.<span class="ruby-identifier">to_hash</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span> }

  <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">data</span> = <span class="ruby-identifier">write_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">session_data</span>, <span class="ruby-identifier">options</span>)
    <span class="ruby-identifier">req</span>.<span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_ERRORS</span>).<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;Warning! #{self.class.name} failed to save session. Content dropped.&quot;</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:defer</span>] <span class="ruby-keyword">and</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:renew</span>]
    <span class="ruby-identifier">req</span>.<span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_ERRORS</span>).<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;Deferring cookie for #{session_id}&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">$VERBOSE</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">cookie</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:value</span>] = <span class="ruby-identifier">cookie_value</span>(<span class="ruby-identifier">data</span>)
    <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:expires</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:expire_after</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:expire_after</span>]
    <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:expires</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:max_age</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:max_age</span>]

    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@same_site</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value">:call</span>
      <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:same_site</span>] = <span class="ruby-ivar">@same_site</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">res</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:same_site</span>] = <span class="ruby-ivar">@same_site</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">set_cookie</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">res</span>, <span class="ruby-identifier">cookie</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">options</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-context" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">context</span><span
            class="method-args">(env, app = @app)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="context-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 263</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">context</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">app</span> = <span class="ruby-ivar">@app</span>)
  <span class="ruby-identifier">req</span> = <span class="ruby-identifier">make_request</span> <span class="ruby-identifier">env</span>
  <span class="ruby-identifier">prepare_session</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>)
  <span class="ruby-identifier">res</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span><span class="ruby-operator">::</span><span class="ruby-constant">Raw</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>
  <span class="ruby-identifier">commit_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">res</span>)
  [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Private Instance Methods</h3>
       </header>

    
      <div id="method-i-commit_session-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">commit_session?</span><span
            class="method-args">(req, session, options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p><a href="../../Session.html"><code>Session</code></a> should be committed if it was loaded, any of specific options like :renew, :drop or :expire_after was given and the security permissions match. Skips if skip is given.</p>
          
          

          
          <div class="method-source-code" id="commit_session-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 342</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">commit_session?</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:skip</span>]
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">has_session</span> = <span class="ruby-identifier">loaded_session?</span>(<span class="ruby-identifier">session</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">forced_session_update?</span>(<span class="ruby-identifier">session</span>, <span class="ruby-identifier">options</span>)
    <span class="ruby-identifier">has_session</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">security_matches?</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-cookie_value" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">cookie_value</span><span
            class="method-args">(data)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="cookie_value-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 408</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cookie_value</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-identifier">data</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-current_session_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">current_session_id</span><span
            class="method-args">(req)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the current session id from the <a href="SessionHash.html"><code>SessionHash</code></a>.</p>
          
          

          
          <div class="method-source-code" id="current_session_id-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">current_session_id</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">req</span>.<span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_SESSION</span>).<span class="ruby-identifier">id</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-delete_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">delete_session</span><span
            class="method-args">(req, sid, options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>All thread safety and session destroy procedures should occur here. Should return a new session id or nil if <a href=":drop">options</a></p>
          
          

          
          <div class="method-source-code" id="delete_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 448</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">sid</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;#delete_session not implemented&#39;</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-extract_session_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">extract_session_id</span><span
            class="method-args">(request)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Extract session id from request object.</p>
          
          

          
          <div class="method-source-code" id="extract_session_id-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 320</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">extract_session_id</span>(<span class="ruby-identifier">request</span>)
  <span class="ruby-identifier">sid</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">cookies</span>[<span class="ruby-ivar">@key</span>]
  <span class="ruby-identifier">sid</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-ivar">@key</span>] <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@cookie_only</span>
  <span class="ruby-identifier">sid</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-find_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">find_session</span><span
            class="method-args">(env, sid)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>All thread safety and session retrieval procedures should occur here. Should return [session_id, session]. If nil is provided as the session id, generation of a new valid id should occur within.</p>
          
          

          
          <div class="method-source-code" id="find_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 433</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_session</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">sid</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;#find_session not implemented.&#39;</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-force_options-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">force_options?</span><span
            class="method-args">(options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="force_options-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 359</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">force_options?</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">options</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">:max_age</span>, <span class="ruby-value">:renew</span>, <span class="ruby-value">:drop</span>, <span class="ruby-value">:defer</span>, <span class="ruby-value">:expire_after</span>).<span class="ruby-identifier">any?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-forced_session_update-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">forced_session_update?</span><span
            class="method-args">(session, options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="forced_session_update-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 355</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">forced_session_update?</span>(<span class="ruby-identifier">session</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">force_options?</span>(<span class="ruby-identifier">options</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">session</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">session</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-generate_sid" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generate_sid</span><span
            class="method-args">(secure = @sid_secure)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Generate a new session id using Ruby rand.  The size of the session id is controlled by the :sidbits option. Monkey patch this to use custom methods for session id generation.</p>
          
          

          
          <div class="method-source-code" id="generate_sid-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 288</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_sid</span>(<span class="ruby-identifier">secure</span> = <span class="ruby-ivar">@sid_secure</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">secure</span>
    <span class="ruby-identifier">secure</span>.<span class="ruby-identifier">hex</span>(<span class="ruby-ivar">@sid_length</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;%0#{@sid_length}x&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-ivar">@sidbits</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">NotImplementedError</span>
  <span class="ruby-identifier">generate_sid</span>(<span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-initialize_sid" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">initialize_sid</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="initialize_sid-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 278</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize_sid</span>
  <span class="ruby-ivar">@sidbits</span> = <span class="ruby-ivar">@default_options</span>[<span class="ruby-value">:sidbits</span>]
  <span class="ruby-ivar">@sid_secure</span> = <span class="ruby-ivar">@default_options</span>[<span class="ruby-value">:secure_random</span>]
  <span class="ruby-ivar">@sid_length</span> = <span class="ruby-ivar">@sidbits</span> <span class="ruby-operator">/</span> <span class="ruby-value">4</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-load_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">load_session</span><span
            class="method-args">(req)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Extracts the session id from provided cookies and passes it and the environment to <a href="Persisted.html#method-i-find_session"><code>find_session</code></a>.</p>
          
          

          
          <div class="method-source-code" id="load_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">load_session</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">sid</span> = <span class="ruby-identifier">current_session_id</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">sid</span>, <span class="ruby-identifier">session</span> = <span class="ruby-identifier">find_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">sid</span>)
  [<span class="ruby-identifier">sid</span>, <span class="ruby-identifier">session</span> <span class="ruby-operator">||</span> {}]
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-loaded_session-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">loaded_session?</span><span
            class="method-args">(session)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="loaded_session-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">loaded_session?</span>(<span class="ruby-identifier">session</span>)
  <span class="ruby-operator">!</span><span class="ruby-identifier">session</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">session_class</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">loaded?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-make_request" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">make_request</span><span
            class="method-args">(env)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="make_request-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 274</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">make_request</span>(<span class="ruby-identifier">env</span>)
  <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">env</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-prepare_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">prepare_session</span><span
            class="method-args">(req)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Sets the lazy session at &#39;rack.session&#39; and places options and session metadata into &#39;rack.session.options&#39;.</p>
          
          

          
          <div class="method-source-code" id="prepare_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 301</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prepare_session</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">session_was</span>               = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">get_header</span> <span class="ruby-constant">RACK_SESSION</span>
  <span class="ruby-identifier">session</span>                   = <span class="ruby-identifier">session_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">req</span>.<span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_SESSION</span>, <span class="ruby-identifier">session</span>
  <span class="ruby-identifier">req</span>.<span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_SESSION_OPTIONS</span>, <span class="ruby-ivar">@default_options</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">session</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">session_was</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">session_was</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-security_matches-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">security_matches?</span><span
            class="method-args">(request, options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="security_matches-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 363</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">security_matches?</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:secure</span>]
  <span class="ruby-identifier">request</span>.<span class="ruby-identifier">ssl?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-session_class" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">session_class</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Allow subclasses to <a href="Persisted.html#method-i-prepare_session"><code>prepare_session</code></a> for different <a href="../../Session.html"><code>Session</code></a> classes</p>
          
          

          
          <div class="method-source-code" id="session_class-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 424</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session_class</span>
  <span class="ruby-constant">SessionHash</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-session_exists-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">session_exists?</span><span
            class="method-args">(req)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Check if the session exists or not.</p>
          
          

          
          <div class="method-source-code" id="session_exists-3F-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 334</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session_exists?</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">value</span> = <span class="ruby-identifier">current_session_id</span>(<span class="ruby-identifier">req</span>)
  <span class="ruby-identifier">value</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-set_cookie" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">set_cookie</span><span
            class="method-args">(request, res, cookie)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Sets the cookie back to the client with session id. We skip the cookie setting if the value didn&#39;t change (sid is the same) or expires was given.</p>
          
          

          
          <div class="method-source-code" id="set_cookie-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 415</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_cookie</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">res</span>, <span class="ruby-identifier">cookie</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">cookies</span>[<span class="ruby-ivar">@key</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:value</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">cookie</span>[<span class="ruby-value">:expires</span>]
    <span class="ruby-identifier">res</span>.<span class="ruby-identifier">set_cookie_header</span> =
      <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">add_cookie_to_header</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">set_cookie_header</span>, <span class="ruby-ivar">@key</span>, <span class="ruby-identifier">cookie</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-write_session" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">write_session</span><span
            class="method-args">(req, sid, session, options)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>All thread safety and session storage procedures should occur here. Must return the session id if the session was saved successfully, or false if the session could not be saved.</p>
          
          

          
          <div class="method-source-code" id="write_session-source">
            <pre><span class="ruby-comment"># File lib/rack/session/abstract/id.rb, line 441</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_session</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">sid</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;#write_session not implemented.&#39;</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>

</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>


Zerion Mini Shell 1.0