Resources

Download Source Code

Summary

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  before_action :verify_session

  private

  def verify_session
    return if session[:remote_ip] == request.remote_ip

    reset_session
    session[:remote_ip] = request.remote_ip
  end
end

# app/views/welcome/index.html.erb
session[:remote_ip] => <%= session[:remote_ip] %><br>
request.remote_ip => <%= request.remote_ip %>