[TYPO3-dev] Session Problem
Stefan.Maurer at inter.de
Stefan.Maurer at inter.de
Thu Aug 16 15:13:32 CEST 2007
Hi,
i am a neebi in Typo3. I have written a php function to put data from the
$_POST array in the session array from
Typo3. My php version works great, but my adabt version for Typo3 makes
Problem here´s the Code:
1. function postToSession($arrayField)
2. {
3. $session =
$GLOBALS["TSFE"]->fe_user->getKey('ses','tx_adcat');
4. if(isset($_POST[$arrayField]))
5. {
6. $session[$arrayField] =
htmlentities($_POST[$arrayField]);
7. }
8.
$GLOBALS["TSFE"]->fe_user->setKey('ses','tx_adcat',$session);
9. $GLOBALS["TSFE"]->storeSessionData();
10. }
So this is my function, it is saved in an extra file functions.php. My
main file is reg.php, the first line of code in this file is:
$session = $GLOBALS["TSFE"]->fe_user->getKey('ses','tx_adcat');
So i can use the Typo3 Session or?
Now the problem i have a form, which checks the send data. If an input of
a field is not correct it marks it red and do not jump
to the next page. When i correct the marked field and send it again, i get
it marked again but the value is corret. When i now
send it again, without doing anything befor sending, the marked field with
the correct input is not anymore makred.
So my script checks at the second time, that my input was ok. The problem
is this function, but i do not know why? I know that
it is this function, because i have used it with the following pseudo code
to test what happens...
1. <?php
2. include("functions.php");
3. error_reporting(E_ALL);
4. $session = $GLOBALS["TSFE"]->fe_user->getKey('ses','tx_adcat');
5. if(!isset($session['site'])) $session['site'] = 1;
6.
7. if(isset($_POST['go'])) $session['site']++;
8.
9. if(isset($_POST['back'])) $session['site']--;
10. $GLOBALS["TSFE"]->fe_user->setKey('ses','tx_adcat',$session);
11. $GLOBALS["TSFE"]->storeSessionData();
12. postToSession('test');
13. print_r($session);
14. echo "<br><br>";
15. print_r($_POST);
16. ?>
17. <form action="index.php?id=25" method="post">
18. <input type="text" name="test" value="<?=$session['test']?>"/>
19. <input type="submit" name="go" value="go"/>
20. <input type="submit" name="back" value="back"/>
21. </form>
Has anybod an idea?
**********************************************************************************************
INTER Krankenversicherung aG
Handelsregister-Nr. HRB 47 beim Amtsgericht Mannheim
INTER Lebensversicherung aG
Handelsregister-Nr. HRB 1666 beim Amtsgericht Mannheim
Handelsregister-Nr. 92 HRB 1960 beim Amtsgericht Berlin-Charlottenburg
INTER Allgemeine Versicherung AG
Handelsregister-Nr. HRB 3181 beim Amtsgericht Mannheim
Alle drei Gesellschaften vertreten durch den Vorstand: Bernd Jansen (Vorsitzender), Jürgen M. Lukas,
Matthias Kreibich
Aufsichtsratsvorsitzender: Jürgen List
**********************************************************************************************
More information about the TYPO3-dev
mailing list