Smart.Framework Logo

final class \SmartSession
{ } ::

Class: SmartSession - provides an Application Session Container.
Depending on the Smart.Framework INIT settings, it can use [files] based session or [user] custom session (example: Redis based session).


class Methods

public static function active ( ) {} :: 
[PUBLIC] Check if Session is Active
returns BOOLEAN TRUE if active, FALSE if not
public static function get ( MIXED $yvariable = null ) {} :: MIXED
@return: {MIXED} (if $yvariable) or $_SESSION[$yvariable] or null if not found or the $yvariable is empty string
@param: {MIXED} $yvariable: variable name to get a specific variable or NULL to get all session data
[PUBLIC] Session Get Variable
public static function set ( string $yvariable, $yvalue ) {} :: BOOLEAN
@return: {BOOLEAN} TRUE if successful, FALSE if not
@param: {STRING} $yvariable: variable name
[PUBLIC] Session Set Variable
public static function unsets ( string $yvariable ) {} :: BOOLEAN
@return: {BOOLEAN} TRUE if successful, FALSE if not
@param: {STRING} $yvariable: variable name
[PUBLIC] Session Unset Variable
public static function start ( ) {} :: 
Start the Session (if not already started).
This function is called automatically when set() or get() is used for a session thus is not mandatory to be called.
It should be called just on special circumstances (Ex: force start session without using set/get).

class Properties


class Constants


Sample code: PHP

<?php

// ## DO NOT USE directly the $_SESSION because session may not be started automatically !!! It starts on first use only ... ##
 // # SAMPLE USAGE #
 //--
 
SmartSession::set('MyVariable''test'); // register a variable to session
 
echo SmartSession::get('MyVariable'); // will get and echo just the $_SESSION['MyVariable']
 
print_r(SmartSession::get()); // will get and prin_r all $_SESSION
 
SmartSession::set('MyVariable'null); // unregister (unset) a variable from session
 //--

// #end php code


documentation generated on: 2023-10-19 23:15:52 +0000


Smart.Framework © 2009-2023 unix-world.org