summaryrefslogtreecommitdiff
path: root/lib/session.php
blob: 5ea6ceb0b3b64c5b98c2705c892d42d3b3d3d336 (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
35
36
<?php

class Session
{
    const SESSION_LIFETIME = 2678400;

    public function open($base_path = '/', $save_path = '')
    {
        if ($save_path !== '') session_save_path($save_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;
    }
}