Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Session active but all session variable are gone on submit

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
stwong
Smarty n00b


Joined: 22 Jun 2020
Posts: 2

PostPosted: Mon Jun 22, 2020 11:06 am    Post subject: Session active but all session variable are gone on submit Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1622

PostPosted: Mon Jun 22, 2020 12:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
stwong
Smarty n00b


Joined: 22 Jun 2020
Posts: 2

PostPosted: Tue Jun 23, 2020 12:59 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP