- Published on
How to access array data from SilverStripe sessions easily
- Authors
- Name
- Frank
Its not evident from the SilverStripe documentation on sessions, but you can access nested array data from SilverStripe sessions using dot notation.
If you save an array of data using the SilverStripe's Session class:
$myArrayOfValues = array('keyword'=>'value');
Session::set('MyArrayOfValues', $myArrayOfValues);
You can access and clear the 'value' above specifically using something like:
$valueFromSession = Session::get("MyArrayOfValues.keyword");
//Clear the value
Session::clear("MyArrayOfValues.keyword");