Image

Imagerayden7 wrote in Imagephp

session varaible data being truncated to a single character

Hi everyone - this is a bit convoluted, so hang with me on this.



Basic problem

I have a session variable which holds a string, and on subsequent page loads of the same page, the data in that session variable is truncated to a single character. So for example,

$_SESSION['myid']
might be "ABCDEF123456" on the first page load, but by the 2nd or 3rd page load, now the variable has been truncated to just "A".






Detailed

I have a PHP script which is basically 3 parts, and when you view the page you see one of the 3 parts, based on your pre-requisites before you view the page. Here's how it works:



  • IF (your entries in the database are not "complete") - you see the page that tells you to go off to another section of the site and "complete" your entries

  • IF (your entries are deemed "complete") - you see a thank-you page for completing, as well as a form that submits to itself, and when the form submits to itself it generates a dynamic PDF (using PDFlib) and forces it out to you ("Content-Disposition: attachment; filename=foo.pdf")

  • IF (your entries are deemed "complete", and you submitted the form to get the PDF) - you see a thank-you page



This is all done from the same PHP script. At the top of the script, I ensure that the

$_SESSION['myid']
and all the other session vars I need exist like this:




if (
      (
         session_is_registered("myid") &&
         session_is_registered("myid_1") &&
         session_is_registered("myid_2")
      )
   )
{



Here's the problem - if you get the second option (your database entries are "complete") and you see the form that creates the PDF for you, the first time you click the "Create PDF" button your session variables are fine, but if you don't wait for the page to load the PDF and you click the "Create PDF" button another couple of times, when you view the source code (which shows the contents of the session varaibles), what used to be

$_SESSION['myid'] = "ABCDEF123456"
now just becomes
$_SESSION['myid'] = "A"
I am totally lost as to why this is happening. Besides this problem, all the other uses of sessions int he site are working just fine. I can post more code samples if needed, but the script is pretty big and compartmentalized, which is why I am just summarizing here. If anybody has any ideas as to what might be happening, please let me know!