User Tools

Site Tools




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]]]] )


  • $TextContent Array
    Text that should be written as content in the user's storage.
  • $Days Int (optional)
    Validity of the cookie in days.
  • $Hours Int (optional)
    Validity of the cookie in hours.
  • $Minutes Int (optional)
    Validity of the cookie in minutes
  • $Seconds Int (optional)
    Validity of the cookie in seconds


  • CookieHandlerException:EC_WRITEERROR (103)
    The cookie couldn't be written
  • CookieHandlerException:EC_INVALIDNUMBER (102)
    One of the validity parameters is no valid number


// 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);
   $LastWebsiteCookie->WriteTextContent ("");
   $LastUserCookie->WriteTextContent ("user0815");
catch (CookieHandlerException $e)
   // [...]
libraries/cookiehandler/cookiehandlerclass/writetextcontent.txt · Last modified: 2022/12/14 20:50 by