PHP Classes

File: app/session.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   PHP IP Logger   app/session.php   Download  
File: app/session.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP IP Logger
Track user IP addresses that access certain pages
Author: By
Last change:
Date: 1 year ago
Size: 895 bytes
 

Contents

Class file image Download
<?php

session_start
();

require_once
'config/config.php';

$utils = new Framework\Utils();

$database = new Framework\Database($config);

$user = new Framework\User($database, $utils);

$auth = new Framework\Authentication($database, $utils);

$current_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

if (isset(
$_SESSION)) {
   
$username = isset($_SESSION['username']) ? $_SESSION['username'] : null;

    if (!isset(
$_SESSION['loggedin'])) {
       
$utils->redirect(SITE_URL . "/login.php");
    }

    if (
$username != null) {
       
$data = $user->getUserData($username);

        if (!isset(
$_SESSION['current_ip'])) {
           
$_SESSION['current_ip'] = $utils->sanitize($_SERVER['REMOTE_ADDR']);
        }

        if (!(isset(
$_SESSION['csrf']))) {
           
$auth->generateSessionToken();
        }
    } else {
       
$utils->redirect(SITE_URL . "/login.php");
    }
}