Session is like an hash to store data with an application request.
It should work if you store a session while login like session[:user]=“Myname_123”
it will renmain in the application until or unless you make it nil
session[:user]=nil
it is versy simple in consept
now session id it is identification of an particular session
and browser you know I use session in android emulator
Session is like an hash to store data with an application request.
It should work if you store a session while login like
session[:user]="Myname_123"
it will renmain in the application until or unless you make it nil
session[:user]=nil
it is versy simple in consept
now session id it is identification of an particular session
and browser you know I use session in android emulator
now your turn
Thanks Rajarshi for your reply!
But that's not my question is - let me put in other way:
If I am using sessionstore, the _session_id has to be passed through
browser cookie. Now, If I disable cookie in the browser the entire
system doesn't work. So, what is the other alternative I can pass the
session id through? if cookie is disabled.
Tried passing as request parameter, but that doesn't work. Any
suggestion plese?
you can use many option
1. memcache to store session in server
2.Activerecord to store session id in database so no need of your
browser
many others
I am using Activerecord only to store the session, but in some way
client has to send that session ID to server to retrieve the logged-in
session data, otherwise each time server will create a new session ID.
Right?
That said, you might remember what PHP does with the PHPSESSIONID parameter appended to all URLs rendered in the page. You might want to do something similar.
It’s not secure, session spoofing is a serious issue. I would encourage not going that route.
It can be done in rails, needs a bit of work but sure. Ideally, you’ll alias_method_chain url_for and read the session in a parent controller, like ApplicationController and initialize your current user and any other session information from that.
It's not secure, session spoofing is a serious issue. I would encourage
not going that route.
It can be done in rails, needs a bit of work but sure. Ideally, you'll
alias_method_chain url_for and read the session in a parent controller,
like ApplicationController and initialize your current user and any
other session information from that.
--
Dheeraj Kumar
Please suggest which route to follow, in order to make application work
even though cookies are disabled in the browser.
I just said what you need. chain the url_for method to add session id to the parameters, and read the session id in your application controller, look it up in your session store, active record or memcache, then load whatever information you want from the database.
I just said what you need. chain the url_for method to add session id to
the parameters, and read the session id in your application controller,
look it up in your session store, active record or memcache, then load
whatever information you want from the database.
--
Dheeraj Kumar
Thanks Dheeraj. Truly appreciate if you can point me to some code
examples for this.
When I try below code in my application controller, it gives an error
saying - undefined method `session_id' for
#<ActionDispatch::Session::AbstractStore::SessionHash:0x13423c80>
def default_url_options(options)
# set a cookie if it's nil
cookies[:_session_id] ||= { :value => 'true', :expires =>
10.seconds.from_now }
{ :_session_id => (request.xhr? ? params[:_session_id] :
session.session_id) } unless cookies[:_session_id]
end
replace session.session_id it with session[:session_id]
I don't think it's a hash with indifferent access.
--
Dheeraj Kumar
No, it doesn't work, it creates a new session id even if I pass a logged
in session ID though URL.
Console log says;
::: Checking session expiry
::: Initializing session expiry. Expires at 2013-01-02 01:30:41 +0530
Redirected to http://localhost:3000/