summaryrefslogtreecommitdiff
path: root/lib/cgi/session.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2021-11-27 18:55:42 +0900
committergit <[email protected]>2021-12-15 08:24:41 +0900
commit6eb500e2df17475a557de536ce24a4d878bf1607 ()
tree1691b3a92cb167485f324d31e3012278647bcfa5 /lib/cgi/session.rb
parente307627b6cdafd830680ccf52bf8832c80326935 (diff)
[ruby/cgi] Extract CGI::Session#new_store_file
https://.com/ruby/cgi/commit/b3e2ff9164
-rw-r--r--lib/cgi/session.rb58
1 files changed, 43 insertions, 15 deletions
@@ -189,6 +189,47 @@ class CGI
end
private :create_new_id
# Create a new CGI::Session object for +request+.
#
# +request+ is an instance of the +CGI+ class (see cgi.rb).
@@ -373,21 +414,8 @@ class CGI
# This session's FileStore file will be created if it does
# not exist, or opened if it does.
def initialize(session, option={})
- dir = option['tmpdir'] || Dir::tmpdir
- prefix = option['prefix'] || 'cgi_sid_'
- suffix = option['suffix'] || ''
- id = session.session_id
- require 'digest/md5'
- md5 = Digest::MD5.hexdigest(id)[0,16]
- @path = dir+"/"+prefix+md5+suffix
- if File::exist? @path
- @hash = nil
- else
- unless session.new_session
- raise CGI::Session::NoSession, "uninitialized session"
- end
- @hash = {}
- end
end
# Restore session state from the session's FileStore file.