Documentation

Class libraries

session

session class library for working with $_SESSION global array.

File: tokernel.framework/lib/session.lib.php

Library methods

void destroy()

Destroy session. This will make the session.lib object useless You need to create a new instance if you need to recreate a new session later. Otherwise, use the regenerate() method

$this->lib->session->destroy();

void regenerate()

Regenerate session id to discard current session data (maybe old) and start over.

$this->lib->session->regenerate();

void set(string $item [, mixed $value = '' ][, string $section = NULL])

Set session value with or without section name.

$this->lib->session->set('last_visit', $data); $this->lib->session->set('last_number', 55); $this->lib->session->set('name', 'John', 'USER');

mixed get(string $item [, string $section = NULL])

Get session value with or without section name.

$vis = $this->lib->session->get('last_visit'); $num = $this->lib->session->get('last_number'); $name = $this->lib->session->get('name', 'USER');

array get_section(string $section)

Get previously defined section as array from session.

// Set values to Section $this->lib->session->set('name', 'John', 'User'); $this->lib->session->set('surname', 'Smit', 'User'); // Get section $section = $this->lib->session->get_section('User'); /* Returns: Array ( [name] => John [surname] => Smit ) */

bool remove([string $item = NULL ][, string $section = NULL])

Remove session item.

// Remove item from section $this->lib->session->remove('name', 'User'); // Remove section $this->lib->session->remove(NULL, 'User'); // Remove item $this->lib->session->remove('name');

Returns false if the given item or section not exist.

bool remove_section(string $section)

Remove section.

$this->lib->session->remove_section('User');

Returns false if the given section not exist.