summaryrefslogtreecommitdiff
path: root/lib/session.php
blob: c5a8271f00bf21199a380ecb613d22e5484b6c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

class Session
{
    const SESSION_LIFETIME = 2678400;

    public function open($base_path = '/')
    {
        session_set_cookie_params(
            self::SESSION_LIFETIME,
            $base_path,
            null,
            isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on',
            true
        );

        session_start();
    }

    public function close()
    {
        session_destroy();
    }

    public function flash($message)
    {
        $_SESSION['flash_message'] = $message;
    }

    public function flashError($message)
    {
        $_SESSION['flash_error_message'] = $message;
    }
}