Converts an array to a JSON string and sets it as cookie content.
e.g. An array like array ('a'⇒1, 'b'⇒2, 'c'⇒3)
is written als content string {“a”:1,“b”:2,“c”:3}
.
Optional a cookie lifespan can be set when the cookie is written as it is done in SetValidity().
Important! As a cookie is part of the HTTP header, the writing of a cookie has to be done before the first output is sent to the browser (even blanks etc.).
void WriteJsonContent ( $JsonArray, [$Days = NULL, [$Hours = NULL, [$Minutes = NULL, [$Seconds = NULL]]]] )
$Cookie = new CookieHandler ("Testcookie"); $UserArray = array ( "name" => "Mr. Smith", "age" => 20 ); try { $Cookie->WriteJsonContent ($UserArray); } catch (CookieHandlerException $e) { // [...] }