views:

134

answers:

8

is there any solution how can i close the browser completely? I need this because I am using Single Sign On from other page and on that page it is written that only closing the browser will log out the user.

A: 

No you cannot force a user's browser to close without their permission.

Edit: Even though there are workarounds for some browsers, it is a bad practice and considered intrusive.

Andy West
ok, I understand. So is there any way I can force the mentioned logout
Peter
As mentioned in other answers, deleting any potential session cookies is likely the best way. Other than that, you can warn users of the risks and ask them to close the browser when they do log out.
Andy West
+4  A: 

You can't close the users browser, but if you can identify the cookie which contains the session, you may be able to clear it. How you would do this depends on the language you are using.

In Javascript, you would have be operating on the same domain as the cookie you want to clear

var expired = new Date();
expired.setTime(mydate.getTime() - 86400);
document.cookie = "my_session_cookie_name=; expires=" + expired.toGMTString();

On the server-side, you can output headers to set or clear cookies. Depending on the users browser settings, you may be able to set cookies on 3rd party domains. Here's an example in PHP

setcookie ('my_session_cookie_name', '', time() - 86400);

//clear cookie for example.com
setcookie('my_session_cookie_name', '', time()-86400, '/', '.example.com');
Paul Dixon
thank you, I'm going to try this solution
Peter
You cannot clear cookies in a third party domain like mentioned here.
Murali VP
If you can set them, you can clear them, there's no difference. It really depends on whether the browser is configured to accept them.
Paul Dixon
Yes, if you can set them you can clear them, because they both are Set-Cookie headers, so my point is you cannot set them across domains (unless the response is from a sub domain such as sub.example.com setting a cookie for .example.com)
Murali VP
You can set them across domains, but depending on the security settings in the browser, they may be blocked, the user may be prompted to confirm, or they may be silently accepted. Here's how you would configure Firefox to block 3rd party cookies: http://support.mozilla.com/en-US/kb/Disabling+third+party+cookies
Paul Dixon
+2  A: 

No, you cannot.

that page it is written that only closing the browser will log out the user

If you could run JavaScript in the right domain (the Single Sign On server's domain), I bet that you can log the user out just by deleting the session cookie.

intgr
A: 

Atleast not in Firefox, otherwise it will be a big usability issue.

delete the cookies when you close the tab.

Priyank Bolia
A: 

it's possible to close browser opened via javascript but since the user open the first browser it won't be possible to close all browsers.

your SSO should have some kind of logout function, it would be better. This function would clear the user cookies or clear the session on the server side.

RageZ
unfortunately this SSO does not provide the logout function. This is the most annoying
Peter
@Peter: no way you can implement it yourself ?
RageZ
SSO is implemented by the other company and I have no access to it
Peter
@Peter: try to know what cookies they are using and clear the cookie from javascript.
RageZ
A: 

Hi

Its very simple,

just add javascript

  <td width="10%"><div align="center"><a href="javascript:window.close() "><font color="#ffffff">Close</font></a></div></td>

thnx

RRaveen
A: 

If each SSO site is given its own cookie, you may need to log the user out of each SSO site individually. Hopefully each site has its own "log me out" URL and you can open a page with multiple iframes to each SSO site.

a paid nerd
A: 

You can set them across domains, but depending on the security settings in the browser, they may be blocked, the user may be prompted to confirm, or they may be silently accepted. Here's how you would configure Firefox to block 3rd party cookies: support.mozilla.com/en-US/kb/…

And how can I set them across domains?

niao

related questions