Session
class Session implements ArrayAccess, IteratorAggregate (View source)
Class for managing HTTP sessions
Provides access to session-state values as well as session-level settings and lifetime management methods. Based on the standard PHP session handling mechanism it provides more advanced features such as expire timeouts.
Constants
STATE_ACTIVE |
|
STATE_INACTIVE |
|
STATE_EXPIRED |
|
STATE_DESTROYED |
|
STATE_ERROR |
|
Methods
Session constructor.
Start a session.
Frees all session variables and destroys all data registered to a session
Restart an expired or locked session.
Create a new session and copy variables from the old one
Re generate the session id.
Get data from the session store
Get all session data.
Get all session data and clean them.
Set data into the session store.
Check whether data exists in the session store
Unset data from the session store
Take all flashes and clean them from bag.
Retrieve an external iterator
Method to get property Bridge
Method to get property Handler
Get session name
Get session id
Shorthand to check if the session is active
Check whether this session is currently created
Method to get property State
Get cookie source, default is $_COOKIE.
Method to get property Options
Method to get property Options
Method to set property options
Get all Session bags.
Get session bag.
Get Flash bag.
Is a property exists or not.
Get a property.
Set a value to property.
Unset a property.
Details
at line line 114
__construct(HandlerInterface $handler = null, SessionBagInterface $bag = null, FlashBagInterface $flashBag = null, SessionBridgeInterface $bridge = null, array $options = array())
Session constructor.
at line line 207
boolean
start()
Start a session.
at line line 262
boolean
destroy()
Frees all session variables and destroys all data registered to a session
This method resets the $_SESSION variable and destroys all of the data associated with the current session in its storage (file or DB). It forces new session to be started after this method is called. It does not unset the session cookie.
at line line 296
boolean
restart()
Restart an expired or locked session.
at line line 323
boolean
fork()
Create a new session and copy variables from the old one
at line line 364
Session
close()
Writes session data and ends session
Session data is usually stored after your script terminated without the need to call close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
at line line 513
mixed
get(string $name, mixed $default = null, string $namespace = 'default')
Get data from the session store
at line line 538
array
getAll(string $namespace = 'default')
Get all session data.
at line line 563
array
takeAll(string $namespace = 'default')
Get all session data and clean them.
at line line 592
Session
clean(string $namespace = 'default')
Clean all data from a bag (namespace).
at line line 611
Session
set(string $name, mixed $value = null, string $namespace = 'default')
Set data into the session store.
at line line 639
boolean
exists(string $name, string $namespace = 'default')
Check whether data exists in the session store
at line line 665
mixed
remove(string $name, string $namespace = 'default')
Unset data from the session store
at line line 706
array
getFlashes()
Take all flashes and clean them from bag.
at line line 720
Traversable
getIterator(string $namespace = 'default')
Retrieve an external iterator
at line line 734
SessionBridgeInterface
getBridge()
Method to get property Bridge
at line line 748
Session
setBridge(SessionBridgeInterface $bridge)
Method to set property bridge
at line line 762
HandlerInterface
getHandler()
Method to get property Handler
at line line 776
Session
setHandler(HandlerInterface $handler)
Method to set property handler
at line line 790
string
getName()
Get session name
at line line 802
string
getId()
Get session id
at line line 814
boolean
isActive()
Shorthand to check if the session is active
at line line 826
boolean
isNew()
Check whether this session is currently created
at line line 864
string
getState()
Method to get property State
at line line 892
array
getCookie()
Get cookie source, default is $_COOKIE.
at line line 913
Session
setCookie(array $cookie)
Set cookie source. default will be $_COOKIE.
Set this property to your array to help you test.
at line line 930
mixed
getOption(string $name, mixed $default = null)
Method to get property Options
at line line 964
array
getOptions()
Method to get property Options
at line line 1006
array
getBags()
Get all Session bags.
at line line 1040
SessionBagInterface
getBag(string $name)
Get session bag.
at line line 1062
Session
setBag(string $name, SessionBagInterface $bag)
Set session bag by name.
at line line 1081
FlashBagInterface
getFlashBag()
Get Flash bag.
at line line 1100
Session
setFlashBag(FlashBagInterface $bag)
Set Flash Bag
at line line 1160
boolean
offsetExists(mixed $offset)
Is a property exists or not.
at line line 1175
mixed
offsetGet(mixed $offset)
Get a property.
at line line 1191
void
offsetSet(mixed $offset, mixed $value)
Set a value to property.
at line line 1206
void
offsetUnset(mixed $offset)
Unset a property.