class SessionsController < ApplicationController def new end def create user = User.find_by(email: params[:email]) # printing to see if user.present is true and the password is the one I have set puts "===================================" puts user.present? puts params[:password] puts "===================================" if user.present? && user.authenticate([params[:password]]) session[:user_id] = user.id redirect_to root_path , notice: "Logged in successfully" else flash[:alert] = "Invalid email or password" render :new end end def destroy session[:user_id] = nil redirect_to root_path, notice: "Logged out" end end