I am changing the value in session
in an api controller, but it doesn't reflect next time the value of that variable in session
is fetched. Here is the api-controller...
module Api
module V0
class RecommendationsApiController < ApplicationController
def x
r1 = session[:last_id]
r2 = some_function(r1)
session[:last_id] = r2
#doesn't reflect in the session next time this same function is called, and the old value is shown
#though checking the value of session at this point shows the right value been set in the @delegate part of the session
end
end
end
end
this is the session_store.rb
Application.config.session_store :cookie_store, key: '_session_name'
application_controller.rb
protect_from_forgery
after_filter :set_csrf_cookie_for_ng
def set_csrf_cookie_for_ng
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
protected
def verified_request?
super || form_authenticity_token == request.headers['X-XSRF-TOKEN']
end
this is websiteApp.run
function.
var csrf_token = $cookies['XSRF-TOKEN'];
$http.defaults.headers.common['X-XSRF-TOKEN'] = csrf_token;
I tried to set the token inside config
, but config
block doesn't have $cookies
. So tried to set headers
inside run
.
Please help out.