# 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()

Starts the session.

Session::start();

Count session variables

count()

Returns the number of elements in the session.

Session::count();

Add session time

addTime(int $time)

Adds time to the session.

Session::addTime(10);

Set session time

setTime(int $time)

Sets the session global time.

Session::setTime(10);

Get remaining time

getRemainingTime([bool $gmdate])

Returns the session remaining time (in seconds).

Session::getRemainingTime();

If true is given as parameter, it will return the remaining time with format (Hours, minutes and seconds).

Session::getRemainingTime(true);

Unset

empty()

Unset the session.

Session::empty();

Destroy

kill()

Destroys the session.

Session::kill();

Variable methods

Set

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

Sets a session variable.

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

Get

get(string $key)

Returns a session variable.

Session::get('name');

Has

has(string $key)

Returns true if a session variable exists, false otherwise.

Session::has('name');

Unset

unset(string $key)

Unset a session variable.

Session::unset('name');

Get variable time

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

Returns the variable time (in seconds).

Session::getVarTime('name');

If true is given as the second parameter, it will return the time with format (Hours, minutes and seconds).

Session::getVarTime('name', true);

Set variable time

setVarTime(string $key, int $time)

Sets the variable live time.

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

Add time to variable

addVarTime(string $key, int $time)

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.