<commit_before><?php

namespace BNETDocs\Libraries;

use CarlBennett\MVC\Libraries\Router;
use CarlBennett\MVC\Libraries\Session as BaseSession;

class Session extends BaseSession  {

  const COOKIE_NAME = 'uid';
  const LOGIN_TTL   = 86400; // 1 day

  public static function checkLogin(Router &$router) {
    // Check if logged in by session but long-term cookie not set
    if (isset($_SESSION['user_id']) && !isset($_COOKIE[self::COOKIE_NAME])) {
      $router->setResponseCookie(
        self::COOKIE_NAME,    // key
        $_SESSION['user_id'], // value
        self::LOGIN_TTL,      // ttl
        true,                 // http only
        true,                 // secure
        getenv('HTTP_HOST'),  // domain
        '/'                   // path
      );
    }
    // Check for login manipulation
    if (isset($_SESSION['user_id']) && isset($_COOKIE[self::COOKIE_NAME])
      && $_SESSION['user_id'] != $_COOKIE[self::COOKIE_NAME]) {
      unset($_SESSION['user_id']);
      $router->setResponseCookie(
        self::COOKIE_NAME, '', 0, true, true, // delete it
        getenv('HTTP_HOST'), '/'
      );
    }
  }

}<commit_msg>Change session cookie ttl to 1 month<commit_after><?php

namespace BNETDocs\Libraries;

use CarlBennett\MVC\Libraries\Router;
use CarlBennett\MVC\Libraries\Session as BaseSession;

class Session extends BaseSession  {

  const COOKIE_NAME = 'uid';
  const LOGIN_TTL   = 2592000; // 1 month

  public static function checkLogin(Router &$router) {
    // Check if logged in by session but long-term cookie not set
    if (isset($_SESSION['user_id']) && !isset($_COOKIE[self::COOKIE_NAME])) {
      $router->setResponseCookie(
        self::COOKIE_NAME,    // key
        $_SESSION['user_id'], // value
        self::LOGIN_TTL,      // ttl
        true,                 // http only
        true,                 // secure
        getenv('HTTP_HOST'),  // domain
        '/'                   // path
      );
    }
    // Check for login manipulation
    if (isset($_SESSION['user_id']) && isset($_COOKIE[self::COOKIE_NAME])
      && $_SESSION['user_id'] != $_COOKIE[self::COOKIE_NAME]) {
      unset($_SESSION['user_id']);
      $router->setResponseCookie(
        self::COOKIE_NAME, '', 0, true, true, // delete it
        getenv('HTTP_HOST'), '/'
      );
    }
  }

}
{'fraction_non_alphanumeric': 0.1436607529208135, 'fraction_numerical': 0.0073561228905235825, 'mean_word_length': 2.3266187050359712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2328600', 'n_tokens_mistral': 743, 'n_tokens_neox': 728, 'n_words': 152}