lib/hayabusa_ext/sessions.rb in hayabusa-0.0.9 vs lib/hayabusa_ext/sessions.rb in hayabusa-0.0.10

- old
+ new

@@ -33,23 +33,40 @@ return [session, hash] end #Generates a new session-ID by the meta data. def session_generate_id(meta) - return Digest::MD5.hexdigest("#{Time.now.to_f}_#{meta["HTTP_HOST"]}_#{meta["REMOTE_HOST"]}_#{meta["HTTP_X_FORWARDED_SERVER"]}_#{meta["HTTP_X_FORWARDED_FOR"]}_#{meta["HTTP_X_FORWARDED_HOST"]}_#{meta["REMOTE_ADDR"]}_#{meta["HTTP_USER_AGENT"]}") + return Digest::MD5.hexdigest("#{Time.now.to_f}_#{meta["HTTP_HOST"]}_#{self.ip(:meta => meta)}_#{meta["HTTP_USER_AGENT"]}") end #Will make the session rememberable for a year. IP wont be checked any more. def session_remember - session = _httpsession.session + httpsession = Thread.current[:hayabusa][:httpsession] + raise "Could not figure out HTTP-session." if !httpsession + session = httpsession.session raise "Could not get session-variable from HTTP-session." if !session session[:remember] = 1 self.cookie( "name" => "HayabusaSession", "value" => _httpsession.session_id, "path" => "/", "expires" => Time.now + 32140800 #add around 12 months + ) + end + + #Will make the session run out as soon as the user closes his browser. + def session_dont_remember + httpsession = Thread.current[:hayabusa][:httpsession] + raise "Could not figure out HTTP-session." if !httpsession + session = httpsession.session + raise "Could not get session-variable from HTTP-session." if !session + session[:remember] = 0 + + self.cookie( + "name" => "HayabusaSession", + "value" => _httpsession.session_id, + "path" => "/" ) end #Writes all session-data to the database (normally it is cached in memory and not updated on change). def sessions_flush \ No newline at end of file