lib/hayabusa_cgi_session.rb in hayabusa-0.0.5 vs lib/hayabusa_cgi_session.rb in hayabusa-0.0.6

- old
+ new

@@ -55,27 +55,32 @@ @page_path = "index.rhtml" if @page_path == "/" @ext = File.extname(@page_path).downcase[1..-1].to_s @resp = Hayabusa::Http_session::Response.new(:socket => self) - @resp.reset(:http_version => http_version, :mode => :cgi) + @resp.reset(:http_version => http_version, :mode => :cgi, :cookie => @cookie) @cgroup = Hayabusa::Http_session::Contentgroup.new(:socket => self, :hb => @hb, :resp => @resp, :httpsession => self) @cgroup.reset @resp.cgroup = @cgroup @resp.header("Content-Type", "text/html") #Set up session-variables. - if @cookie["HayabusaSession"].to_s.length > 0 + if !@cookie["HayabusaSession"].to_s.empty? @session_id = @cookie["HayabusaSession"] elsif @browser["browser"] == "bot" @session_id = "bot" else @session_id = @hb.session_generate_id(@meta) send_cookie = true end + + #Set the 'ip'-variable which is required for sessions. + @ip = @meta["REMOTE_ADDR"] + raise "No 'ip'-variable was set: '#{@meta}'." if !@ip + raise "'session_id' was not valid." if @session_id.to_s.strip.empty? begin @session, @session_hash = @hb.session_fromid(@ip, @session_id, @meta) rescue ArgumentError => e #User should not have the session he asked for because of invalid user-agent or invalid IP. \ No newline at end of file