Assuming you have a named_route for your logout action, you could try
function bunload() {
document.location.href="<%= logout_path %>";
}
However, I would point out that unload isn't guaranteed to be called &
is even less likely to call & wait to load a new resource so that you
can kill the session. Additionally, it's usually a mark of spam sites
(they do alert popups), so if at all possible you should avoid
onunload.
In reality, if you are using Rails defaults, the session is all stored
on the client anyway, so there is no server load to have the session
naturally expire when the browser quits (not when a user opens a
different url or closes the window). If you are storing sessions on
the server, you can easily setup a sweeper to clear out sessions not
accessed in some time (or set that as a default in your environment)
Niels
instead of logout_path m giving string "/user/logout" which is the url
for logout but its not working why.
please help..
rahul
m trying to call my user controller logout action from onunload
function