WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\framework\session

class SessionsManager

Class Methods Summary

public static function close()Saves the state of the active session and close it.public static function destroy()Destroy the active session.public static function get(string$varName)Returns the value of a session variable.public static function getActiveSession()Returns the currently active session.public static function getCookiesHeaders()Returns an array that contains cookies headers values.public static function getSessionIDFromCookie(string$sessionName)Returns the ID of a session from a cookie given its name.public static function getSessionIDFromRequest(unkown_type$seesionName)Return session ID from session cookie, get or post parameter.public static function getSessions()Returns an indexed array that contains all created sessions.public static function getStorage()Returns storage engine which is used to store sessions state.public function hasCookie()Checks if the given session name has a cookie or not.public static function hasSession(string$sName)Checks if the manager has specific session or not.public static function newId()Generate new ID for the active session.public static function pauseAll()Stores the status of all sessions and pause them.public static function pull(string$varName)Retrieves the value of a session variable and removes it from the session.public static function remove(string$varName)Removes the value of a session variable from the active session.public static function reset()Reset sessions manager to defaults.public static function set(string$varName, mixed$value)Sets session variable.public static function setStorage(SesstionStorage$storage)Sets sessions storage engine.public static function start(string$sessionName, array$options)Starts new session or resumes an existing one.public static function validateStorage()Validate the current status of the storage.

Class Methods Details

public static function close()Saves the state of the active session and close it. public static function destroy()Destroy the active session. Calling this method when there is no active session will have no effect.public static function get(string$varName)Returns the value of a session variable. The value will be taken from the active session.

Parameters:

  • string $varName The name of the variable.
Returns: null|mixedIf a variable which has the given name is found, its value is returned. If no such variable exist or there was no active session, the method will return null.
public static function getActiveSession()Returns the currently active session. Returns: Session|nullIf a session is active, the method will return an object of type 'Session' that contains session information. If no session is active, the method will return null.public static function getCookiesHeaders()Returns an array that contains cookies headers values. The returned values can be used to create cookies for sessions.Returns: arrayThe method will return an array that contains headers values that can be used to create sessions cookies.public static function getSessionIDFromCookie(string$sessionName)Returns the ID of a session from a cookie given its name.

Parameters:

  • string $sessionName The name of the session.
Returns: boolean|stringIf the ID is found, the method will return it. If the session cookie was not found, the method will return false.
public static function getSessionIDFromRequest(unkown_type$seesionName)Return session ID from session cookie, get or post parameter.

Parameters:

  • unkown_type $seesionName
Returns: string|booleanIf session ID is found, the method will return it. Note that if it is in a cookie, the name of the cookie must be the name of the session in order to take the ID from it. If it is in GET or POST request, it must be in a parameter with the name 'session-id'.
public static function getSessions()Returns an indexed array that contains all created sessions. Returns: arrayAn array that contains objects of type 'Session'.public static function getStorage()Returns storage engine which is used to store sessions state. Returns: SessionStorage public function hasCookie()Checks if the given session name has a cookie or not. Returns: booleantrue if a cookie with the name of the session is fount. false otherwise.public static function hasSession(string$sName)Checks if the manager has specific session or not.

Parameters:

  • string $sName The name of the session.
Returns: booleanIf the manager manages a session which has the given name, the method will return true. False otherwise.
public static function newId()Generate new ID for the active session. Returns: string|nullIf there was an active session and new ID is generated for it, the method will return the new ID. Other than that, the method will return null.public static function pauseAll()Stores the status of all sessions and pause them. public static function pull(string$varName)Retrieves the value of a session variable and removes it from the session.

Parameters:

  • string $varName The name of the variable.
Returns: mixed|nullIf the variable exist and its value is set, the method will return its value. If the value is not set or no session is active, the method will return null.
public static function remove(string$varName)Removes the value of a session variable from the active session.

Parameters:

  • string $varName The name of the variable.
Returns: booleanIf the value was deleted, the method will return true. If the does not exist or no session is active, the method will return false.
public static function reset()Reset sessions manager to defaults. public static function set(string$varName, mixed$value)Sets session variable. Note that session variable will be set only if there was an active session.

Parameters:

  • string $varName The name of the variable. Must be non-empty string.
  • mixed $value The value of the variable. It can be any thing.
Returns: booleanIf the variable is set, the method will return true. If not, the method will return false.
public static function setStorage(SesstionStorage$storage)Sets sessions storage engine. This method is used to create a custom sessions storage engine. The framework by default provide one type which is file storage. The developer can implement a custom storage engine using the interface 'SessionStorage'.

Parameters:

  • SesstionStorage $storage The new sessions storage.
public static function start(string$sessionName, array$options)Starts new session or resumes an existing one. The method will first checks if a session which has the given name exist. if there was such session, it will pause all sessions and resumes selected one. If no session was found which has the given name, the method will initialize new session.

Parameters:

  • string $sessionName The name of the session that will be resumed or created.
  • array $options An array that contains session options. Available options are:
    • duration: The duration of the session in minutes. Must be a number greater than or equal to 0. If 0 is given, it means the session is not persistent.
    • refresh: A boolean which is set to true if session timeout time will be refreshed with every request. Default is false.
public static function validateStorage()Validate the current status of the storage. This method will go through all sessions which was activated and check the status of each one. If the session is new, paused or resumed, the method will store session state using specified storage engine. If the status of the session is killed, the method will remove session state from the storage. In addition to that, the method will garbage-collect all sessions which are not active any more. The garbage collection algorithm will depends on the way the developer have implemented his own sessions storage engine.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024