Cms_VisitorPreferences class
Defined in |
/modules/cms/classes/cms_visitorpreferences.php, lines 17-64 |
Author |
LemonStand eCommerce Inc. |
Allows to save visitor preferences into the server session.
The Cms_VisitorPreferences is a multi-purpose class which allows to save visitor
preferences into the server session storage and load them when it is needed.
Please remember that the values saved using this class are stored in the session object,
and not bound to a specific customer. The server distinguishes visitors using cookies,
so visitor preferences should be considered as temporary. This data storing method
is reliable during a visitor browsing session, but you should not rely on it
for storing important or sensitive data. Use this class for storing non critical
data, for example preferred product sorting modes.
Method |
Description |
Defined By |
get() |
returns a value, previously saved to the with the set() method. Example:. |
Cms_VisitorPreferences |
set() |
saves a value. Example:. |
Cms_VisitorPreferences |
Method details
¶
get() method
public static mixed get(string $name, mixed $default=NULL)
$name |
string |
specifies the name (identifier) of the saved value. |
$default |
mixed |
specifies a default value.
This value will be used in case if the value with the specified name doesn't
exist in the session. |
{return} |
mixed |
returns the loaded value or the default value. |
Returns a value, previously saved to the with the set() method. Example:
$color = Cms_VisitorPreferences::get('color', 'red');
¶
set() method
public static void set(string $name, mixed $value)
$name |
string |
specifies the name (identifier) of the value. |
$value |
mixed |
specifies a value to save.
The value can be scalar, array or object. |
Saves a value. Example:
Cms_VisitorPreferences::set('color', 'blue');
|