Problems with sessions
Posted: Fri Feb 23, 2007 1:09 pm
Hi,
I've created an image validation script in PHP, which generates graphical letters on top of an image using GD2 library. I want to ask the users to type in what's on this image to prevent someone repeatedly trying to guess passwords on my password pages by programming their own browser.
The PHP script, validate.php, sends JPG headers to the browser, and I get the image onto the page in an img tag:
In my image validator generation script validate.php, I turn on sessions, and I save the random 5 digit code I render to the image to the session 'verify_code'.
Here's the problem. When I try and access the session from the php script in which the <img> tag is placed, it doesn't show up as a recorded index.
Curious, I've checked the directory in which my PHP install is writing session data, and lo and behold, it is using different unique session id's for the validate.php script, and the script in which the image is rendered.
Therefore I can't access the verify code from the script I need to.
Why are the sessions different, and is there any way I make them the same (sounds like something that's difficult, but I've got to ask)?
Many thanks
I've created an image validation script in PHP, which generates graphical letters on top of an image using GD2 library. I want to ask the users to type in what's on this image to prevent someone repeatedly trying to guess passwords on my password pages by programming their own browser.
The PHP script, validate.php, sends JPG headers to the browser, and I get the image onto the page in an img tag:
Code: Select all
<img src="validate.php"/>Here's the problem. When I try and access the session from the php script in which the <img> tag is placed, it doesn't show up as a recorded index.
Curious, I've checked the directory in which my PHP install is writing session data, and lo and behold, it is using different unique session id's for the validate.php script, and the script in which the image is rendered.
Therefore I can't access the verify code from the script I need to.
Why are the sessions different, and is there any way I make them the same (sounds like something that's difficult, but I've got to ask)?
Many thanks