在连接失效时间后执行操作

时间:2018-01-21 22:14:41

标签: javascript php timestamp session-variables

大家好,我已经有一段时间了,因为我正在寻找我的问题的解决方案我正在开发一个Web应用程序,那天我就阻止了。

目标是从用户连接开始一段时间后我做出精确的动作。

我不会给所有代码太长,所以我会尝试尽可能简单:

我的第一个PHP脚本1验证用户登录并创建一个占用当前时间的会话变量,然后将用户返回到PHP脚本2:

 session_start();
 .
 .
 .// some code ....
 if(password_verify($password,$pass_sql))
        {

             $_SESSION['autorisation'] = 'oui';
             $_SESSION['ConnectOK'] = true;

             $_SESSION['login'] = $login;
             $_SESSION['debut'] = time(); // this is the variable of time

            header("Location:http://jawad.meswatts.fr/sous/meswatts.php");
        }

meswatts.php:

 <?php 
 session_start();
 if(  !empty($_SESSION['autorisation']) AND  $_SESSION['autorisation'] =='oui' )        
  {
      $t_navigation = time();
      if($t_navigation - $_SESSION['debut'] >= 12 )
        {
            echo " hello" ; // just exemple of action
        }
     .
     .
     .
     . //the rest of the code is only HTML that is not very important




   }     
?>

所以在第二个PHP脚本中,我仍然使用时间函数,我使用我在第一页中创建的会话变量进行减法,因此在12秒后会有一个动作,不幸的是它不会在通过12秒什么都没有发生任何帮助会有所帮助!

0 个答案:

没有答案