[Typo3] help with session variables
Ronald Renfro
rrenfro at ilovehtml.net
Sun Jan 30 22:00:32 CET 2005
hi,
according to the TS_REF varibales can be stored in session (frontend no
login) by a calls to
$GLOBALS["TSFE"]->fe_user->getKey() and
$GLOBALS["TSFE"]->fe_user->setKey().
I setup a simple testing script for a cart and a typoscript template
that calls my class function. Somehow I cannot get any data stored in
session. debug($GLOBALS['TSFE']->fe_user) shows that sesData is empty
etc... I am stuck.
any help would be great!
Here is what I have got:
Typoscript template:
---------------------
includeLibs.wsm = fileadmin/scripts/user_test.php
page = PAGE
page.typeNum=0
page.30 = USER_INT
page.30 {
userFunc = user_test->listCart
}
Class file:
---------------------
class user_test {
function listCart($content,$conf) {
$GLOBALS['TSFE']->set_no_cache();
// read data from session
if ($GLOBALS["TSFE"]->loginUser) {
$cartData = $GLOBALS["TSFE"]->fe_user->getKey("user","cartData");
} else {
$cartData = $GLOBALS["TSFE"]->fe_user->getKey("ses","cartData");
}
// add data to session
if(! is_array($cartData)) {
$cartData = array();
$cartData["name"] = "paul";
$cartData["address"] = "Main street";
$cartData["shipping"] = "express";
$cartData["total"] = "50";
} else {
// simple test
$cartData["total"] = $cartData["total"] +1;
}
$GLOBALS['TSFE']->fe_user->setKey("ses","cartData", $cartData);
$GLOBALS['TSFE']->storeSessionData();
$str = "Cart: ";
if(is_array($cartData)) {
foreach($cartData as $k => $v) {
$str .= $k.":".$v."<br />";
}
} else {
$str .= "empty";
}
return $str;
}
}
Ronnie Renfro
Ronnie Renfro
rrenfro at markgraph.de
More information about the TYPO3-english
mailing list