Guest User

Untitled

a guest
Jun 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1.  
  2. class UserSession < CGI::Session
  3. def initialize( request, option = {} )
  4. # use only when testing, otherwise server log will get huge
  5. # @debug = true
  6.  
  7. @username = option['username']
  8. super( request, option );
  9.  
  10. $stderr << "Using session id '#{self.session_id}' for user '#{self['username']}'\n" unless @debug.nil?
  11. end
  12.  
  13. def create_new_id
  14. raise 'Missing username for new session' if @username.nil?
  15.  
  16. @new_session = true
  17. return @username
  18. hash = Digest::MD5.hexdigest("alscore-#{@username}.session")
  19.  
  20. @new_session = true
  21. $stderr << "Created session id '#{hash}' for user '#{@username}'\n" unless @debug.nil?
  22. hash
  23. end
  24. end
Add Comment
Please, Sign In to add comment