Can somebody tell me the right way to set/use session variables in a ruby on rails application from scratch. I am not able to set/use a session variable in my controller between two pages. I am using CookieStore session type. This is the syntax being used to set and get session variables:
session[:test] = "testing"
@test_str = session[:test]
Let me know in case I am missing on something.
This is how my controller looks like:
class PaymentsController < ApplicationController
# GET /merchant_test
def merchant_test
session[:test] = "testing"
render :layout => false
end
# POST /post_to_mobikwik
def post_to_mobikwik
zr = Mobikwik::Request.new(params)
@mobikwik_data = zr.all_params
@test_str = session[:test]
render :layout => false
end
# POST /z_response
def z_response
zr = Mobikwik::Response.new(request.raw_post)
@checksum_check = zr.valid?
@mobikwik_post = zr.all_params
@statuscode = @mobikwik_post['statuscode']
@statusmessage = @mobikwik_post['statusmessage']
if @statuscode == "0"
@verified = zr.verified?
else
@verified = false
end
render :layout => false
end
testentry. If it does not, your cookie could contain too much information (limited to 4K). One other reason why it could fail is that your session is reset, somehow. The information will be in the cookie, but not in the session (since it is cleared). Look for thereset_sessioncommand somewhere in abefore_action/filter(e.g. it is generally done after log in to disable session fixation).