PHP Mini Documentation

PHPSession
in package
implements SessionBag

PHP Mini Framework

Tags
copyright

busarm.com

license

https://github.com/Busarm/php-mini/blob/master/LICENSE (MIT License)

link
https://github.com/josantonius/php-session

Interfaces, Classes, Traits and Enums

SessionBag
PHP Mini Framework

Table of Contents

$options  : array<string|int, mixed>
__construct()  : mixed
__toString()  : string
Gets a string representation of the object
all()  : array<string|int, mixed>
Get all attributes
clear()  : void
Remove all attribute
destroy()  : bool
Destroy session
get()  : mixed
Get attribute
getId()  : string
Gets the session ID.
getName()  : string
Gets the session name.
has()  : bool
Checks if an attribute exists
isStarted()  : bool
Checks if the session is started.
pull()  : mixed
Deletes an attribute by name and returns its value.
regenerate()  : bool
Regenerate session
remove()  : void
Remove attribute
replace()  : void
Set bulk attributes
set()  : bool
Set attribute
setId()  : void
Sets the session ID.
start()  : bool
Start session
touch()  : void
Touch session to update last access or expiry date
throwIfHasWrongOptions()  : void
Throw exception if the session have wrong options.
throwIfHeadersSent()  : void
Throw exception if headers have already been sent.
throwIfNotStarted()  : void
Throw exception if the session was not started.
throwIfStarted()  : void
Throw exception if the session has already been started.

Properties

$options

private array<string|int, mixed> $options = []
Tags

Methods

__construct()

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

List of available $options with their default values:

  • cache_expire: "180" (minutes)
  • cache_limiter: "nocache"
  • cookie_domain: ""
  • cookie_httponly: "0"
  • cookie_lifetime: "0"
  • cookie_path: "/"
  • cookie_samesite: ""
  • cookie_secure: "0"
  • gc_divisor: "100"
  • gc_maxlifetime: "1440"
  • gc_probability: "1"
  • lazy_write: "1"
  • name: "PHPSESSID"
  • read_and_close: "0"
  • referer_check: ""
  • save_handler: "files"
  • save_path: ""
  • serialize_handler: "php"
  • sid_bits_per_character: "4"
  • sid_length: "32"
  • trans_sid_hosts: $_SERVER['HTTP_HOST']
  • trans_sid_tags: "a=href,area=href,frame=src,form="
  • use_cookies: "1"
  • use_only_cookies: "1"
  • use_strict_mode: "0"
  • use_trans_sid: "0"
Tags
throws
SessionError
Return values
mixed

__toString()

Gets a string representation of the object

public __toString() : string
Tags
Return values
string

Returns the string representation of the object.

all()

Get all attributes

public all() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get()

Get attribute

public get(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string
$default : mixed = null
Tags
Return values
mixed

getId()

Gets the session ID.

public getId() : string
Tags
Return values
string

getName()

Gets the session name.

public getName() : string
Tags
Return values
string

has()

Checks if an attribute exists

public has(string $name) : bool
Parameters
$name : string
Tags
Return values
bool

isStarted()

Checks if the session is started.

public isStarted() : bool
Tags
Return values
bool

pull()

Deletes an attribute by name and returns its value.

public pull(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string
$default : mixed = null
Tags
throws
SessionError
Return values
mixed

regenerate()

Regenerate session

public regenerate([bool $deleteOld = false ]) : bool
Parameters
$deleteOld : bool = false
Tags
Return values
bool

remove()

Remove attribute

public remove(string $name) : void
Parameters
$name : string
Tags
throws
SessionError
Return values
void

replace()

Set bulk attributes

public replace(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Tags
throws
SessionError
Return values
void

set()

Set attribute

public set(string $name, mixed $value[, mixed $options = NULL ]) : bool
Parameters
$name : string
$value : mixed
$options : mixed = NULL
Tags
throws
SessionError
Return values
bool

setId()

Sets the session ID.

public setId(string $sessionId) : void
Parameters
$sessionId : string
Tags
throws
SessionError
Return values
void

touch()

Touch session to update last access or expiry date

public touch(string $name) : void
Parameters
$name : string
Tags
Return values
void

throwIfHasWrongOptions()

Throw exception if the session have wrong options.

private throwIfHasWrongOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>
Tags
throws
SessionError
Return values
void

throwIfHeadersSent()

Throw exception if headers have already been sent.

private throwIfHeadersSent() : void
Tags
throws
SessionError
Return values
void

throwIfNotStarted()

Throw exception if the session was not started.

private throwIfNotStarted() : void
Tags
throws
SessionError
Return values
void

throwIfStarted()

Throw exception if the session has already been started.

private throwIfStarted() : void
Tags
throws
SessionError
Return values
void

        

Search results