```ruby
class SessionsController < ApplicationController


  def new
  end

  def create
	  user = User.find_by_email(params[:email])
    # If the user exists AND the password entered is correct.
    if user && user.authenticate(params[:password])
      # Save the user id inside the browser cookie. This is how we keep the user 
      # logged in when they navigate around our website.
      session[:user_id] = user.id
      redirect_to '/'
    else
    # If user's login doesn't work, send them back to the login form.
      redirect_to '/login'
    end
  end

  def destroy
	  session[:user_id] = nil
    redirect_to '/login'
  end

end
```

Use SHA1 for login page
user
```ruby
class SessionsController < ApplicationController


  def new
  end

  def create
    email = Digest::SHA1.hexdigest params[:email].to_s
    pass = Digest::SHA1.hexdigest params[:password]

	  user = User.find_by_email(email)
    # If the user exists AND the password entered is correct.
    if user && user.authenticate(pass)
      # Save the user id inside the browser cookie. This is how we keep the user 
      # logged in when they navigate around our website.
      session[:user_id] = user.id
      redirect_to '/'
    else
    # If user's login doesn't work, send them back to the login form.
      redirect_to '/login'
    end
  end

  def destroy
	  session[:user_id] = nil
    redirect_to '/login'
  end

end
```
assistant