Session
in package

The Session class manages all the sets and gets stored in the PHP $_SESSION.

This class has been created to manage the gets and the sets against $_SESSION ensuring certain data coordination for example between the API session and the PHP session. Developers should manage all the session interactions through this specific Session class instead of directly using the $_SESSION PHP structure. At initialization, if the user does not yet have a session, then empty objects are assigned to the session instance and will be used later to save the session information such as: user, visualization theme, product comparator,...

Tags
see
Session::getInstance()
see
Session::start()
see
Session::reset()
see
Session::isInit()
see
Session::setBasketToken()
see
Session::getBasketToken()
see
Session::initRoute()
see
Session::getDefaultTheme()
see
Session::getGeneralSettings()
see
Session::isInitLastVersion()
see
Session::addBatchRequests()
see
Session::setUser()
see
Session::getUser()
see
Session::setAggregateDataFromApiRequest()
see
Session::setAggregateData()
see
Session::getAggregateData()

Table of Contents

AGGREGATE_DATA  = 'aggregateData'
BASKET  = 'basket'
GENERAL_SETTINGS  = 'generalSettings'
ORDERS  = 'orders'
PRODUCT_COMPARISON  = 'productComparison'
SESSION_AGGREGATE_DATA  = 'sessionAggregateData'
SESSION_VERSION  = '20220921'
USER  = 'user'
VALUES  = 'values'
$aggregateData  : SessionAggregateData|null
$basket  : Basket|null
$basketToken  : string|null
$defaultRoute  : Route|null
$defaultTheme  : Theme|null
$generalSettings  : SessionGeneralSettings|null
$orders  : array<string|int, mixed>
$user  : User|null
$values  : array<string|int, mixed>
addOrder() This method add a order to session.  : void
addValue() This method add session value.  : void
getAggregateData() This method returns the session aggregate data.  : SessionAggregateData
getBasket() This method returns the session Basket.  : Basket
getBasketToken() This method returns the basket token stored in the session (null if it is not set).  : string
getDefaultRoute() This method returns the session default Route.  : Route
getDefaultTheme() This method returns the session default Theme.  : Theme
getGeneralSettings() This method returns the session general settings.  : SessionGeneralSettings
getInstance() This method returns the instance of the session.  : self
getOrder() This method returns the session order, by given id.  : User
getOrders() This method returns the session orders.  : array<string|int, mixed>
getProductComparison() This method returns the session ProductComparison.  : ProductComparison
getUser() This method returns the session User.  : User
getValue() This method return session add value by given key.  : mixed|null
getValues() This method return session add values.  : array<string|int, mixed>
initRoute() This method sets the session route variables (LOCALE, CURRENCY, COUNTRY, LANGUAGE, DEFAULT_THEME, GENERAL_SETTINGS) based on the given Route instance.  : void
isInit() This method returns true if the session has been initialized and false otherwise.  : bool
isInitLastVersion() This method returns true if the last version of the session has been initialized and false otherwise.  : bool
reset() This method resets the session.  : void
setAggregateData() This method sets the given SessionAggregateData to the session.  : void
setAggregateDataBasket() This method sets Bastek items to the session's SessionAggregateData.  : void
setAggregateDataFromApiRequest() This method sets the aggregate data of the session generating a request of this data to the API to obtain an update of them and setting them to the session.  : void
setAggregateDataProductComparison() This method sets ProductComparison items to the session's SessionAggregateData.  : void
setAggregateDataWishlist() This method sets Wishlist items to the session's SessionAggregateData.  : void
setBasket() This method sets the given basket to the session.  : void
setBasketToken() This method sets the basket token.  : void
setProductComparison() This method sets the given ProductComparison to the session.  : void
setUser() This method sets the given user to the session.  : void
start() This method starts the session and returns true if all is ok.  : bool
commitSession()  : mixed
destroySession()  : void
initSelfProperties() This method runs when start the session.  : void
setDefaultGeneralSettings()  : void
setSessionProperties()  : mixed
startReadSession()  : mixed
startSessionEvent() This method runs when start the session.  : void
startWritableSession()  : bool

Constants

AGGREGATE_DATA

public mixed AGGREGATE_DATA = 'aggregateData'

BASKET

public mixed BASKET = 'basket'

GENERAL_SETTINGS

public mixed GENERAL_SETTINGS = 'generalSettings'

ORDERS

public mixed ORDERS = 'orders'

PRODUCT_COMPARISON

public mixed PRODUCT_COMPARISON = 'productComparison'

SESSION_AGGREGATE_DATA

public mixed SESSION_AGGREGATE_DATA = 'sessionAggregateData'

SESSION_VERSION

public mixed SESSION_VERSION = '20220921'

VALUES

public mixed VALUES = 'values'

Properties

$aggregateData

protected SessionAggregateData|null $aggregateData = null

$basket

protected Basket|null $basket = null

$basketToken

protected string|null $basketToken = null

$defaultRoute

protected Route|null $defaultRoute = null

$defaultTheme

protected Theme|null $defaultTheme = null

$orders

protected array<string|int, mixed> $orders = []

$user

protected User|null $user = null

$values

protected array<string|int, mixed> $values = []

Methods

addOrder()

This method add a order to session.

public addOrder(PaymentValidationResponse $pvr) : void
Parameters
$pvr : PaymentValidationResponse
Return values
void

addValue()

This method add session value.

public final addValue(string $key, mixed $value[, bool $override = true ]) : void
Parameters
$key : string
$value : mixed
$override : bool = true
Return values
void

getAggregateData()

This method returns the session aggregate data.

public getAggregateData() : SessionAggregateData
Return values
SessionAggregateData

getBasket()

This method returns the session Basket.

public getBasket() : Basket
Return values
Basket

getBasketToken()

This method returns the basket token stored in the session (null if it is not set).

public getBasketToken() : string
Return values
string

getDefaultRoute()

This method returns the session default Route.

public getDefaultRoute() : Route
Return values
Route

getDefaultTheme()

This method returns the session default Theme.

public getDefaultTheme() : Theme
Return values
Theme

getInstance()

This method returns the instance of the session.

public final static getInstance() : self
Return values
self

getOrder()

This method returns the session order, by given id.

public getOrder(int $id) : User
Parameters
$id : int
Return values
User

getOrders()

This method returns the session orders.

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

getProductComparison()

This method returns the session ProductComparison.

public getProductComparison() : ProductComparison
Return values
ProductComparison

getUser()

This method returns the session User.

public getUser() : User
Return values
User

getValue()

This method return session add value by given key.

public final getValue(string $key) : mixed|null
Parameters
$key : string
Return values
mixed|null

getValues()

This method return session add values.

public final getValues() : array<string|int, mixed>
Return values
array<string|int, mixed>

initRoute()

This method sets the session route variables (LOCALE, CURRENCY, COUNTRY, LANGUAGE, DEFAULT_THEME, GENERAL_SETTINGS) based on the given Route instance.

public initRoute(Route $route) : void
Parameters
$route : Route
Return values
void

isInit()

This method returns true if the session has been initialized and false otherwise.

public isInit() : bool
Return values
bool

isInitLastVersion()

This method returns true if the last version of the session has been initialized and false otherwise.

public isInitLastVersion() : bool
Return values
bool

reset()

This method resets the session.

public reset() : void
Return values
void

setAggregateData()

This method sets the given SessionAggregateData to the session.

public setAggregateData([SessionAggregateData $sessionAggregateData = null ]) : void
Parameters
$sessionAggregateData : SessionAggregateData = null
Return values
void

setAggregateDataBasket()

This method sets Bastek items to the session's SessionAggregateData.

public setAggregateDataBasket(Basket $basket) : void
Parameters
$basket : Basket
Return values
void

setAggregateDataFromApiRequest()

This method sets the aggregate data of the session generating a request of this data to the API to obtain an update of them and setting them to the session.

public setAggregateDataFromApiRequest() : void
Return values
void

setAggregateDataProductComparison()

This method sets ProductComparison items to the session's SessionAggregateData.

public setAggregateDataProductComparison(int $id, string $action) : void
Parameters
$id : int
$action : string
Return values
void

setAggregateDataWishlist()

This method sets Wishlist items to the session's SessionAggregateData.

public setAggregateDataWishlist(int $id, string $action) : void
Parameters
$id : int
$action : string
Return values
void

setBasket()

This method sets the given basket to the session.

public setBasket([Basket $basket = null ]) : void
Parameters
$basket : Basket = null
Return values
void

setBasketToken()

This method sets the basket token.

public setBasketToken() : void
Return values
void

setProductComparison()

This method sets the given ProductComparison to the session.

public setProductComparison(ProductComparison $productComparison) : void
Parameters
$productComparison : ProductComparison
Return values
void

setUser()

This method sets the given user to the session.

public setUser([User $user = null ]) : void
Parameters
$user : User = null
Return values
void

start()

This method starts the session and returns true if all is ok.

public start() : bool
Return values
bool

commitSession()

protected commitSession([bool $initSelfProperties = true ]) : mixed
Parameters
$initSelfProperties : bool = true
Return values
mixed

destroySession()

protected destroySession() : void
Return values
void

initSelfProperties()

This method runs when start the session.

protected initSelfProperties() : void
Return values
void

setDefaultGeneralSettings()

protected setDefaultGeneralSettings(array<string|int, mixed> $storeURL) : void
Parameters
$storeURL : array<string|int, mixed>
Return values
void

setSessionProperties()

protected setSessionProperties() : mixed
Return values
mixed

startReadSession()

protected startReadSession() : mixed
Return values
mixed

startSessionEvent()

This method runs when start the session.

protected startSessionEvent() : void
Return values
void

startWritableSession()

protected startWritableSession() : bool
Return values
bool

Search results