Jump to main content
University Computer Centre
Cookies module

Display of a cookie notice

We provide a central function to display in a uniform look a notice about the use of cookies that require a privacy notice.

Inclusion of the cookies module

To use the function, the php/cookies.inc file must be loaded for all relevant scripts. The function call can be made directly afterwards. It is therefore recommended to define all this in the centrally used config.inc file.

<?php
    …
    require_once('php/cookies.inc');
    //function cookies() available
    …
?>

Funktion
cookies(string $directory, string $text, string $link[, string $linktext[, string $buttontext]])

$directory
  • directory for which (including subdirectories) the cookie hint is valid
$text
  • text with basic user information
$link
  • link to privacy policy
$linktext
  • text of the link to the privacy policy
  • optional (default 'Mehr Informationen' (more information))
$buttontext
  • text of the button to close the cookie hint
  • optional (default 'Verstanden' (understood))
Graphical explanation of the parameters of the cookies() function

Example PHP code

require_once('php/cookies.inc');
cookies('/urz/www/',
        'This website uses cookies. […]',
        '/urz/www/cookies/privacy.html',
        '(Privacy Policy)',
        'Accepted');

Error codes

An error message is displayed in a red frame before the start of the page content if the input parameters are invalid. Thus at least a hint to the "cookies module" appears, if already the desired user hint cannot be rendered.

The following error numbers currently exist:

1
  • Specification for $directory incorrect (must start with '/' and be part of the current script path)
2
  • Specification for $text incorrect (must contain a hint about the use of cookies)
3
  • Specification for $link incorrect
4
  • Specification for $linktext too short
5
  • Specification for $buttontext too short