[TYPO3-english] Session check / Error when calling setKey() or getKey()
Jigal van Hemert
jigal.van.hemert at typo3.org
Tue Mar 20 08:02:10 CET 2012
Hi,
On 20-3-2012 0:14, Benoit Montereau wrote:
> The original check (agains multiple ratings) made with tx_ratings
> extensions is either 100% open or based on IP address. Unfortunately, IP
> check is a litle bit to strong: 2-3 users sharing the same Internet access
> cannot rate the same item.
>
> Therefore I would like to base my check on a session level.
>
> So I tried to add some code to the class tx_ratings_ajax in protected
> function updateRating() but I'm getting errors as soon as I try to call
> either
>
> $GLOBALS['TSFE']->fe_user->setKey('ses',"mysess", "myvalue");
> or
> $GLOBALS['TSFE']->fe_user->getKey('ses',"mysess");
>
> Error is *Fatal error*: Call to a member function setKey() on a non-object
> in...
tx_ratings_ajax is an eID script which means that it uses a very limited
TYPO3 frontend. As you can see in the constructor even the database must
be explicitly connected. This also implies that there is not TSFE object
available.
You can create a TSFE by calling tslib_eidtools::initFeUser(); , but
beware that this requires a lot of processing; see comments in this
function:
* Load and initialize Frontend User. Note, this process is slow because
* it creates a calls many objects. Call this method only if necessary!
Maybe using a cookie is a light-weight solution?
--
Jigal van Hemert
TYPO3 v4 Core Team member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-english
mailing list