# Session

Wolff\Core\Session

Instead of managing the $_SESSION variable directly, you can use the Wolff Session class.

It's safer since it's tied to the client's IP address and its user agent, meaning that if the client has a different IP or a different user agent, the session will be destroyed.

General methods

All the session methods works with the time expressed in minutes (unless it’s specified other way).

Start session

start(): void

Starts the session.

Session::start();

Add session time

addTime(int $time): void

Adds time to the session.

Session::addTime(10);

Set session time

setTime(int $time): void

Sets the session global time.

Session::setTime(10);

Get remaining time

getRemainingTime([bool $gmdate]): mixed

Returns the session remaining time (in seconds).

Session::getRemainingTime();

If a string is given as parameter, it will return the remaining time in the given date format.

Session::getRemainingTime('H:m:s');

Empty

empty(): void

Removes the session data.

Session::empty();

Destroy

kill(): void

Destroys the session.

Session::kill();

Variable methods

Set

set(string $key, $value[, int $time]): void

Sets a session variable.

Session::set('name', $value);

Get

get(string $key): mixed

Returns a session variable.

Session::get('name');

Has

has(string $key): bool

Returns true if a session variable exists, false otherwise.

Session::has('name');

Unset

unset(string $key): void

Unsets a session variable.

Session::unset('name');

Get variable time

getVarTime(string $key[, bool $gmdate]): mixed

Returns the variable time (in seconds).

Session::getVarTime('name');

If a string is given as the second parameter, it will return the time in the given date format.

Session::getVarTime('name', 'H:m:s');

Set variable time

setVarTime(string $key, int $time): void

Sets the variable live time.

Session::setVarTime('name', 10);

Add time to variable

addVarTime(string $key, int $time): void

Adds time to a variable.

Session::addVarTime('name', 10);
Documentation made with
Something is wrong in here? Make a issue/pull request on the repo.