Having followed a tutorial online, I have a sessions controller that looks like:
class SessionsController < ApplicationController
def new
end
def create
user = User.authenticate(params[:email], params[:password])
if user
session[:user_id] = user.id
redirect_to root_url, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
end
end
def destroy
session[:user_id] = nil
redirect_to root_url, :notice => "Logged out!"
end
end
There is no model & database table to back this up, although login does work. Is there any way for me to list the logged in users, or would that not be possible? How does the server persist sessions if they are not stored someplace?
How about this:
Update a field called last seen
and then do a find for all users last seen within the last X minutes