douwen5951 2019-02-27 06:27
浏览 366

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

I'm developing a website using 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

  • 写回答

1条回答 默认 最新

  • douzhaocheng4533 2019-02-27 06:33
    关注

    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.

    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). If not it redirects.

    Not tested … just to give you an idea.

    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来