|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
stwong Smarty n00b
Joined: 22 Jun 2020 Posts: 2
|
Posted: Mon Jun 22, 2020 11:06 am Post subject: Session active but all session variable are gone on submit |
|
|
Hi, I'm newbie to PHP and Smarty and migrating some PHP codes written by others to new server.
The main PHP script has some session variables defined. However, after displaying a template:
$smarty->display('show_form.tpl');
all session variables are gone:
- session_status shows session is active
- session_id shows the correct session id
- /var/lib/php/session/sess_xxx file becomes empty after submitting the form in the template.
the template is a simply form looks like following:
<form name=myForm onSubmit="return validatePwd()" method="POST" action="{$smarty.server.PHP_SELF} ">
session_start() is called at the very beginning of the main PHP script.
Besides sessions variables, all variable defined are also lost,eg.
$b1 = $_SESSION['logined'];
We're using PHP 7.2.24 bundled with CentOS8.
And using Smarty 2.6.30 (not using Smarty 3.x to minimize change of the PHP code...).
Would anyone please help?
Thanks a lot. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jun 22, 2020 12:31 pm Post subject: |
|
|
Check network traffic (from browser dev. tools). Is the session cookie correctly passed back and forth?
Any errors in the logs? Perhaps, your PHP is unable to write session state.
(Short answer: not a Smarty issue.) |
|
Back to top |
|
stwong Smarty n00b
Joined: 22 Jun 2020 Posts: 2
|
Posted: Tue Jun 23, 2020 12:59 am Post subject: |
|
|
I think network traffic are passed through. The PHP script write some _POST variables to _SESSION and can see them in the session file under /var/lib/php/sess_xxx. Then the variables in the file are gone upon submitting the form within the template.
There is no error logged.
>Short answer: not a Smarty issue.
Thanks, will do more debugging and maybe post in PHP forum. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|