I have a PHP code with 2 pages.
Page 1: allows for loading of variable inputs into several arrays and then into several SESSION variables created using these arrays.
Page 2: creates and displays a png utilizing all the SESSION variables and using “imagecreate”.
Sometimes, randomly, page 2 does not always load all the SESSION variables before the pgn is created, leading to a malformed image.
Refreshing page 2 then creates the correct image, confirming that all the SESSION variables are finally being passed to page 2.
Can the png creation be delayed until after all SESSION variables are loaded or is there another solution?
You should not use SESSION variable for such data as your question states
variable inputs into several arrays and then into several SESSION variables created using these arrays.
As your traffic grows you will run out of disk space if you store a large data for each user in your session storage.
Instead of SESSION
variable use localStorage
of your user's browser for your need, they'll be faster and much less load on your disk space.
Thanks for the replies. The problem was not loading the SESSION variables, it was loading the cached image rather than the newly created image. Included a timestamp in the image name and this solved the problem. i.e $plan[time()] = imagecreatetruecolor( 1000, 1000 );