Developer's Manual  Function Reference  Working with server variables  getCookieVar

getCookieVar

Returns value of requested cookie.


mixed getCookieVar
(string var_name [, mixed default_value])

The function getGetVar returns the value of requested cookie or default_value if the cookie doesn't exist. If default_value is omitted the function returns zero.

Example

<?
// If the cookie value was not set the function
// returns zero and the script prints 'First time visit' text
$lastVisitDate = getCookieVar('lastVisitDate');
if(!
$lastVisitDate)
    echo
"First time visit";

// If the cookie value was not set the function returns '800' as a string
$defaultWidth = getCookieVar('defaultWidth', '800');
?>
Please login to add comments.