Armin
Armin

Reputation: 15968

Is it possible to get $_COOKIE with TypoScript?

In TypoScript exists the possibility to get the environment variable HTTP_COOKIE_VARS (which is deprecated):

10 = TEXT
10.data = global : HTTP_COOKIE_VARS | some_cookie

I got this from the documentation.

But on my server (PHP 5.3) this variable is empty! I suppose this is because this environment variable is deprecated. Now I am running out of options, without using an extension, user function or user condition.

Maybe you have an idea! Thanks in advance.

Upvotes: 2

Views: 3969

Answers (3)

Dieter Lehmann
Dieter Lehmann

Reputation: 1

[request.getCookieParams()['some_cookie'] == 'some_value']
Your Code
[end]

Upvotes: -1

maholtz
maholtz

Reputation: 3631

this should do the job (at least with TYPO3 4.5 and PHP 5.3.8):

10 = TEXT
10.data = global:_COOKIE|some_cookie
10.wrap = <h2>Cookie: |</h2>

Upvotes: 9

konsolenfreddy
konsolenfreddy

Reputation: 9671

Unfortunately, there is no built-in functionality for the $_COOKIE variable.

You can however write a hook which implements the tslib_content_getDataHook interface and register it via

$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'][] = 'path/to/your/class.user_cookiehook.php';

Upvotes: 0

Related Questions