Forum: Ruby on Rails Session Problem with Ajax Call

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
selva (Guest)
on 2007-06-19 07:57
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
selva (Guest)
on 2007-06-19 12:25
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
Dee Z. (Guest)
on 2007-06-22 11:24
(Received via mailing list)
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
This topic is locked and can not be replied to.