开发者

Logout functionality For Zendesk in Pure JavaScript

I want to implement a logout function. When a user clicks Logout, I want to end their session and redirect to another page. Sadly, I am limited to only JavaScript.

EDIT: Moving this over to Zendesk because it seems like they have a Remote Authentication API.

Thank you to al开发者_高级运维l the people who answered.


Assuming your login session state is stored in a cookie that isn't httpOnly, you can simply delete the login cookie by setting its expiry date to a the past. For example, using this cookie library:

$.cookie('login_cookie_name', null);

Then you can just do a location.assign('/logged_out_page.html'); to redirect to another page.


It depends on what server technology you're using.

Let's say there's a logout.aspx page. You could just do an AJAX request to that page to zap the session, or delete a cookie that the application might be using to cache authentication, then redirect like so:

window.location = "http://www.mysite.com/logout.aspx";

UPDATE

I just found this post on SO that should help (that wasn't easy):
https://stackoverflow.com/questions/3237476/zendesk-remote-auth-using-java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜