How can I redirect to home when user click on back button after logout?

落爺英雄遲暮 提交于 2019-12-13 05:41:56

问题


I was wondering how can I redirect users to my hompage after they logged out when they hit the back button, kind of like facebook does. I was playing around with some javascript but nothing seemed to work.

PS: This will be for a Wordpress theme.


回答1:


Hi there check the wp_logout_url($redirect_url).




回答2:


If you use sessions, you can check if the user is logged in when viewing an authenticated page, and if not, send the headers to your homepage.




回答3:


Javascript seems like the way to do it. Simply check if the user is logged and if not, do a redirect to the home page via a document.location = "http://my.home.page";

I guess that you have the session in PHP too so you could just do the redirect there instead of relying on Javascript.

header ('Location: http://your.home.page');


来源:https://stackoverflow.com/questions/5194566/how-can-i-redirect-to-home-when-user-click-on-back-button-after-logout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!