app/controllers/application_controller.rb
#Clean up cookies and session on InvalidAuthenticityRequest
Clean up cookies and session on InvalidAuthenticityRequest
Clean up cookies and session on InvalidAuthenticityRequest
def invalid_authenticity_request
    sign_out(current_user)
    cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
    render error: 'invalid token', status: :unprocessable_entity
  end
def invalid_authenticity_request sign_out ( current_user ) cookies [ 'XSRF-TOKEN' ] = form_authenticity_token if protect_against_forgery? render error : 'invalid token' , status : :unprocessable_entity end
Clean up cookies and session on InvalidAuthenticityRequest
Clean up cookies and session on InvalidAuthenticityRequest