[英]Redirect to signin page if user deletes browser history
I'm developing a website using php. 我正在使用php开发网站。 Now my question is, Is there a way to redirect to signin page, if the user deletes browser history.
现在我的问题是,如果用户删除浏览器历史记录,是否可以重定向到登录页面。 I have searched.
我已经搜寻了。 But didn't found any way.
但是没有找到任何办法。
Regards, Sasi 问候,萨西
You cannot do that because it is not possible / not allowed to access browser history … there may be some ways but accessing the users browser history is definitely a hit on privacy and most likely illegal in most countries. 您不能这样做,因为它不可能/不允许访问浏览器历史记录……可能有一些方法,但是访问用户的浏览器历史记录绝对是对隐私的打击,在大多数国家中,这很可能是非法的。
Whatever you want to achieve there are better and more robust solutions for that than "stealing" your users history. 无论您要实现什么目标,都有比“窃取”用户历史记录更好和更强大的解决方案。 For example Cookies, Local/Session Storage or PHP Sessions.
例如Cookies,本地/会话存储或PHP会话。
As requested a sample … This is not exactly what you want (which is not possible because you can't access history) but maybe an alternative: 根据要求提供一个样本……这并不是您想要的(这不可能,因为您无法访问历史记录),但是可能是另一种选择:
session_start();
$check = time() - 300; // 5 Minutes
if( !isset( $_SESSION[ 'login' ] ) OR $_SESSION[ 'login' ] > $check ):
header( 'Location: ./login.php' );
exit;
endif;
$_SESSION[ 'login' ] = time();
This should be placed on every page (except login) as first code. 这应该作为第一个代码放置在每个页面上(登录除外)。 It sets/refreshes on every load a timestamp in a session variable.
它在每次加载时设置/刷新会话变量中的时间戳。 Before that it checks if the variable exists or if the time difference is to big (5 minutes).
在此之前,它将检查变量是否存在或时差是否过大(5分钟)。 If not it redirects.
如果不是,它将重定向。
Not tested … just to give you an idea. 未经测试……只是给您一个想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.