Session lost after form submission

I have developed form containing more than ten sections and each section contains more than 20 fields. For all these sections I have created one table that has upto 400 columns.
I have included that form at Patient/Client -> Visit forms -> my_form. I have used OpenEMR code methods (functions; viz. getPatientData() ) for accessing patients details based on patient ID ($pid), which is stored in session and also using OpenEMR code method (function; viz getEncounterDateByEncounter()), which retrieves encounter date based on encounter ID ($encounter), which is stored in session from current session.
After multiple submissions of form, $pid and $encounter from session becomes 0 for sometime and again after consecutive submissions of form, we get the correct $pid and $encounter from session
Does anyone has ever come across such kind of scenario? If so, what would be the approach to solve this problem?
I am following below steps for accessing form (I have included my_form in left navigation into left_nav.php)

  1. Login with OpenEMR (admin - user)
  2. Go to Patient/Client -> pateints
  3. Open encounter
  4. After opening encounter go to Patient/Client -> Visit forms -> my_form.

If this occurs during stress test then I can see losing session set. Suggest using globals.

Thanks for reply sjpadgett, I have also tried to use global session i.e. $_SESSION[‘pid’] and $_SESSION[‘encounter’] giving same error. Can you please suggest me other options.

@nikeeta
Did the entire session gets empty or only these two values $_SESSION[‘pid’] and $_SESSION[‘encounter’] get’s empty.
The entire session values will be unset only in following two scenarios,

  1. When the authCloseSession() function in library/auth.inc is called [OR]
  2. While using multiple sites.

Please share more information on this.

Thanks,
ViSolve

I changed how session cookies are handle awhile back to address multisite issues. Session cookies directory are now based on webroot so not sure if in v5.0.0 but for sure in 5.0.1.
@nikeeta Before calling form call top.restoreSession() first.

@visolveemr
Thanks for replay, we had included the “include_once("$srcdir/auth.inc")” script into our form but we didn’t use the “authCloseSession()” function in our form and we do not have multiple site deployment we have only single site deployment.

$_SESSION[‘pid’] and $_SESSION[‘encounter’] get empty while trying to submit the form therefore we are not able to submit form data.
When same-time I am tried to view the encounter summery I am able view it successfully but when tried to view form it’s not displayed.

Prob if you call top.restoreSession() before calling form you will be set.

@Nilesh_Hake,
In general, while saving the form it will be submitted to save.php file.Have you included globals.php in save.php file?
All session variables are defined in globals.php file, so you have to include this file in all pages/files where session variables are needed.

Thanks,
ViSolve

Thanks for reply sjpadgett and visolveemr. We could reach to solution of this issue. In header of save.php script we have added one message which is returned to new.php page after saving. The message consists of $_POST[‘pid’] and $_POST[‘encounter’] which were retrieved from new.php before saving and those values were then used as $pid and $eid next time.

Thanks
Nikeeta