I have a WordPress page which redirects to an external page which then redirects back to a page on my server.
page 1
<?php
session_start();
include('../../../wp-load.php');
$varPostData = $x. '|' . $y. '|' . $z. '|' . $a. '|' . $b. '|' . $c. '|' . $d. '|' . $e. '|' . $f. '|' . $g. '|' . $h. '|' . $i. '|' . $j. '|' . $k;
$_SESSION['PostData'] = $varPostData;
//some redirect code
exit();
page 2
<?php
session_start();
$PostDataArray = explode('|', $_SESSION['PostData']);
On the first page I have data stored in a SESSION variable and I want to read it on the second page on my server once user has been redirected back to my page.
My setup works (has been working for more than a year), however sometimes maybe once in 50 times it just doesn't work. The data doesn't get passed to the new page from SESSION it's empty. What's weird is that the data is there in the session file on the server, but it just doesn't get read by the page.
This "bug" has intensified lately. Where previously it happened rarely (like one in 50 or 100 times) now it happens like one in 6 times.
This makes me suspect that it's due to server configuration. I am on Ubuntu with php 5.6 and here's part of my php.ini that has to do with sessions.
I am baffled since I have no clue where to start and what's more I can't replicate the problem, I just know that it happens.
I went through this check list and everything checks out
- session_start(); is called at the top of the page(s), no spaces no nothing
- end the script with exit(); after redirect
- it's WordPress with login so the users would't be able to login if there were no cookies
- register_globals doesn't exist in php 5.6 so I don't think this applies?
- I made sure the session isn't deleted or emptied (it's there the file exists in /var/lib/php/)
- I made sure that the $_SESSION super-global isn't being deleted.
- I am redirecting to the same domain with www
- my extensions are php (it works most of the time)
Further I checked the access logs and there is no other page/asset requested from the server between the two pages (so no different sessions anything).
What am I missing? Any clue will be helpful.