Session Problem with Ajax Call


#1

Hai,

I am totally new to Ajax. I am trying to use ajax in my project. Its

working fine, I am getting problem while session time expires. If
session expires means i am redirecting to login page.Onclick i am
calling on ajax function. It will goto controller and it will check the
session if session expires then it has to goto login page.

 On ajax call i am updating the div. If session expires means its

calling the login page, but it updating that div.

Regards
Selvaraj


#2

any idea???

selva wrote:

Hai,

I am totally new to Ajax. I am trying to use ajax in my project. Its

working fine, I am getting problem while session time expires. If
session expires means i am redirecting to login page.Onclick i am
calling on ajax function. It will goto controller and it will check the
session if session expires then it has to goto login page.

 On ajax call i am updating the div. If session expires means its

calling the login page, but it updating that div.

Regards
Selvaraj


#3

selva wrote:

Hai,

I am totally new to Ajax. I am trying to use ajax in my project. Its

working fine, I am getting problem while session time expires. If
session expires means i am redirecting to login page.Onclick i am
calling on ajax function. It will goto controller and it will check the
session if session expires then it has to goto login page.

Your “session_expired” filter should check if this is an xhr request, if
yes a redirection is needed you’ll have to send back javascript
redirection snippet:

return unless session expired?
flash[:notice] = “Your session expired”
if request.xhr?
render :update do |page|
page.redirect_to login_path
end
else
redirect_to login_path
end
false

best,
zsombor


Company - http://primalgrasp.com
Thoughts - http://deezsombor.blogspot.com