Session in Rails_API gem

Hi Rails Guru, Currently I am working i my project, and that project
using
rails_api gem. I want to add session management for authentication, but
it
seems the session does not working. Here is my configuration in
config/initializer/session_store.rb:

Pmcapi::Application.config.session_store :cookie_store, {

key: ‘_pmcapi_session’,
expire_after: 1.hour

}

And I add config.api_only = false in application.rb (
http://stackoverflow.com/questions/15342710/adding-cookie-session-store-back-to-rails-api-app
)

and in my session_controller, I adding session to store token

(in session_controller.rb)

def create
#just to generate new token
user.reset_sso_token!
session[:token] ||= user.sso_token
self.current_user = user
redirect_to root_path
end

when i am in application_controller, i want to access session[:token]
but
the result is nil (in application_controller.rb)

def authenticate_user!
#puts(“User Authentication”)
#puts(request.authorization)
#puts(request)
@user = User.authenticate_with_token(session[:token])
#head :unauthorized unless @user.present?
redirect_to sign_in_path if @user.nil?
end

Please, i need help. I have stucked with this, thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs