CookieHandler::WriteTextContent()


Definition

Writes the given Text as cookie content.
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 WriteTextContent ( $TextContent, [$Days = NULL, [$Hours = NULL, [$Minutes = NULL, [$Seconds = NULL]]]] )

Parameters

Exceptions

Example

// Stores the last visited website (expires at the end of the browser session)
$LastWebsiteCookie = new CookieHandler ("LastWebsite");
// Stores the last used username (expires after 2 hours)
$LastUserCookie    = new CookieHandler ("LastUser", 0, 2);
 
try 
{
   $LastWebsiteCookie->WriteTextContent ("www.domain.com");
   $LastUserCookie->WriteTextContent ("user0815");
}
catch (CookieHandlerException $e)
{
   // [...]
}