如何设置会话超时以及超时后或用户是否关闭浏览器使用更新查询

时间:2017-05-17 10:02:39

标签: php query-string

**How to update table on session timeout**

$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (1 * 60); 
if (isset($_SESSION['Seats']))
{

**if session start then update first query**

    $seatS=$_SESSION['Seats'];
    $Eventid=$_POST["Eventid"];




$stmt = $con->prepare('UPDATE fistevent SET `Status`="Hold" where `Event_Id`=? AND `seats`="'.$seatS.'" ');
$stmt->bind_param("s", $_POST["Eventid"]);
 $stmt->execute();
else
{
 $now = time();
**check current time and if session time is over update second query**
         if ($now > $_SESSION['expire']) {
            session_destroy();
            $seat=$_POST['finalSeats'];
            $Eventid=$_POST["Eventid"];
**sql Injection Protect**

$ stmt = $ con> prepare('UPDATE fistevent SET Status =“”其中Event_Id =?AND seats =“'。$ seat。'”AND { {1}} =“保持”');                  $ stmt-> bind_param(“s”,$ _POST [“Eventid”]);                  $ stmt->执行();

0 个答案:

没有答案