简体   繁体   English

如果用户删除浏览器历史记录,则重定向到登录页面

[英]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.

相关问题 在 Firebase 和 HTML 中成功注册或登录后如何将用户重定向到另一个页面 - How to redirect user to another page after successfully SignUp or SignIn in Firebase and HTML 登录后重定向页面-AngularJS和Kinvey - Redirect page after signIn - Angularjs and Kinvey 防止框架中具有页面重定向的iframe包含在浏览器的后退按钮/历史记录中 - prevent an iframe with a page redirect in the frame from being included in browser's back button/history 如何获得指向重定向页面的链接以显示在浏览器的历史记录中? - How can I get links to a redirect page to show up in the browser's history? 是否可以使用 JavaScript 和 HTML 在不清除页面历史记录的情况下将用户重定向到另一个页面? - Is it possible to redirect a user to another page without clearing their history of the page using JavaScript & HTML? 如何基于浏览器用户代理重定向页面? - How do I redirect a page based on the browser user agent? 打开反应应用程序应重定向到默认登录页面 - opening react app should redirect to default signin page 使用历史推送重定向用户反应 - Redirect user using the history push in react 告诉用户何时返回浏览器历史记录 - Tell when a user is going back in browser history 找出用户在浏览器历史记录中的位置 - Find out where in browser history the user is
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM