[TYPO3-dev] How can I detect a logged in fronted user?

Michiel Roos michiel at netcreators.com
Tue Jun 12 13:11:34 CEST 2007


Bernd,

Thank you for this elaborate explanation.

I want to detect if a frontend user is logged in using mod_rewrite, not 
TYPO3.

I am having problems with this because the fe_typo_user cookie is 
allways set, even if the frontend user never logs in.

Kind regards,


Michiel

Bernd Wilke wrote:
> "Michiel Roos" <michiel at netcreators.com> schrieb im Newsbeitrag
> news:mailman.1.1181638213.16668.typo3-dev at lists.netfielders.de...
>> Dear list,
>>
>> When a backend user logs in the be_typo_user cookie is set.
>>
>> This can successfully be detected by mod_rewrite using the condition:
>> RewriteCond %{HTTP_COOKIE} !be_typo_user
>>
>> After which it will continue is there is no backend user logged in.
>>
>> I want to do the same for a frontend TYPO3 user but am unable to because
>> . . . . .
>>
>> The fe_typo_user cookie is allways set!
>>
>> Even if a user never logs in.
>>
>> When a user does log in, the cookie does not change and no new cookies
>> are set.
>>
>> My aim is to be able to use:
>> RewriteCond %{HTTP_COOKIE} !fe_typo_user
>>
>> So that I can skip rewriting to statically cached files if a frontend
>> user is logged in.
>>
>> Currently this is not possible since the cookie is always there.
>>
>> Why is the cookie always set?
>>
>> If this behavior cannot be changed easily I am thinking of hooking into
>> the frontend login code to set an extra: no_static cookie which I can
>> check against.
>>
>> Can some guru enlighten me here please?
> 
> in an extension you normaly didn't ask cookies but PHP-variables, as TYPO3
> is PHP.
> 
> BE-User:    $GLOBALS['BE_USER']->user
> FE-User:    $GLOBALS['TSFE']->fe_user->user
> 
> if an user is logged in there are fields with values, especially
> ...['uid']!=0.
> 
> 
> if you are using typoscript and want to decide on BE- and FE-user you can
> use these conditions:
> 
> [globalVar = TSFE : beUserLogin > 0]
> # BE-user logged in
> [global]
> 
> [loginUser = fe_users-uid1, fe_users-uid2, ...]
> # any of these FE-users is logged in
> [global]
> 
> [loginUser = *]
> # any FE-user is logged in
> [global]
> 
> [usergroup = *]
> # any FE-user is logged in (because every FE-user is at least in one
> usergroup)
> [global]
> 
> [usergroup = 1,2]
> # a FE-user belonging to these groups is logged in
> [global]
> 
> 
> Bernd
> --
> http://www.pi-phi.de/t3v4/cheatsheet.html
> 




More information about the TYPO3-dev mailing list