Proyecto en colaboración con OPASO

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /* Authors : Carlos C. Corrada-Bravo
  3. David J. Ortiz-Rivera
  4. Organization : Centro de Desarrollo y Consultoria Computacional
  5. Project : OPASO Material Registry
  6. File : header
  7. Description : Handle session expiry for OPASO */
  8. /* start user session */
  9. if(!isset($_SESSION)){
  10. session_start();
  11. }
  12. /* check for expired session */
  13. if(!isset($_SESSION["last_activity"]) or (time() - $_SESSION["last_activity"]) > 1800){
  14. session_unset();
  15. session_destroy();
  16. $_SESSION = array();
  17. header("Location: /?error=session_expired");
  18. die();
  19. }
  20. /* update last activity */
  21. else{
  22. $_SESSION["last_activity"] = time();
  23. }
  24. /* update session id, after 30 mins */
  25. if((time() - $_SESSION["created"]) > 1800){
  26. session_regenerate_id(true);
  27. $_SESSION["created"] = time();
  28. }
  29. ?>