<?php

  session_start();

  include('cookies.php');

  $sessionactive = array_key_exists('login_appquadrata', $_SESSION) ? $_SESSION['login_appquadrata'] : '';



  if ($sessionactive==1) {

    

    if ($_SESSION['login_appquadrata']==0) 

    {

      echo"<script language='javascript'>window.location='../login'</script>;";

      exit();

    }

  }

  else

  {

    echo"<script language='javascript'>window.location='../login'</script>;";

  }

  

  /*if ($_SESSION['status_appquadrata']==1) 

    {

      //Elimina las cookies

      $objeto = new galletas();

      $cookie_name = "onstar_appquadrata";

      $cookie_value = "";

      $objeto->Agregargalleta($cookie_name,$cookie_value);

      $objeto = new galletas();

      $cookie_name = "tokenusu_appquadrata";

      $cookie_value = "";

      $objeto->Agregargalleta($cookie_name,$cookie_value);

      $cookie_name = "token_appquadrata";

      $cookie_value = "";

      $objeto->Agregargalleta($cookie_name,$cookie_value);

      $_SESSION['login_appquadrata']=0;

      echo"<script language='javascript'>window.location='/login/?error=<p>Tu usuario esta desactivado contacta a soporte.<br/><a class=link href=tel:014422280003>Tel:2-28-00-03</a> | <a class=link href=mailto:soporte@ubiqmed.com>soporte@ubiqmed.com</a><p>'</script>;";

    }*/



?>

  <script language='javascript'>

    var session="blueprint";        

    function get_session() {

              var xmlhttp = new XMLHttpRequest();

              xmlhttp.onreadystatechange = function() {

                  if (this.readyState == 4 && this.status == 200) {

                      session= this.responseText;

                if(session.trim().length === 0)

                {

                  window.location='../login'         

                }

                else

                {

                  // alert('La Session sigue activa');

                }    

                  }

              }

              xmlhttp.open("GET", "../onstar.php?Token_appquadrata=UkKA1590", true);

              xmlhttp.send();

          }



          function get_session_local_cookie(cname)

          {

                var name = cname + "=";

    var decodedCookie = decodeURIComponent(document.cookie);

    var ca = decodedCookie.split(';');

    for(var i = 0; i < ca.length; i++) {

        var c = ca[i];

        while (c.charAt(0) == '') {

            c = c.substring(1);

        }

        if (c.indexOf(name) == 0) {

          // alert(c.substring(name.length, c.length));

            return c.substring(name.length, c.length);

        }

    }

    window.location='../logout.php';

    return "";

          }



          function Queen_Guard() {

            // get_session_local_cookie("onstar_centinela");

            //Descomentar get_session(); solo que se busca es que.

            get_session();

              setTimeout(Queen_Guard, 1000);

          }

  </script>

