check.php 579 B

123456789101112131415161718192021222324
  1. <?php
  2. //Recup de la session
  3. if(!isset($_COOKIE['salon']) || !isset($_COOKIE['common-sess'])){
  4. exit(json_encode(['etat' => 'err']));
  5. }
  6. if($_COOKIE['common-sess'] != $_COOKIE['salon']){
  7. exit(json_encode(['etat' => 'err']));
  8. }
  9. //Lancement session
  10. session_name('common-sess');
  11. session_start();
  12. //Compare les ids
  13. if(!isset($_POST['id'])){
  14. exit(json_encode(['etat' => 'erre']));
  15. }
  16. $json = ['etat' => 'ok', 'update' => false];
  17. if($_POST['id'] != count($_SESSION['roll'])){
  18. $json['update'] = true;
  19. $_SESSION['id'] = $_POST['id'];
  20. }
  21. echo json_encode($json);