vuthao / cool-php-captcha

Automatically exported from code.google.com/p/cool-php-captcha
GNU General Public License v3.0
0 stars 0 forks source link

Image code executed twice in some browsers. #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I.
Only tested in Google chrome 2.0 and Opera 9.64.

1. Add some session variable incremented each time image is loaded.
2. Draw its value in debug mode.
3. Try refreshing page/captcha (1st, 2nd and both, several times).

II. 
Fast refresh of page with captcha in example-form (check up will fail once 
even with corrent answer).

What is the expected output? What do you see instead?
It looks like "captcha" session variable is refreshed after the image is 
already drawn. That means that any attempt to enter the word from image 
will fail.

What version of the product are you using? On what operating system?
cool-php-captcha-0.2.1 on windows XP SP3 (browsers and there listed above).

Please provide any additional information below.

Original issue reported on code.google.com by free.goo...@gmail.com on 26 Jun 2009 at 6:38

GoogleCodeExporter commented 8 years ago
Sorry, submitted by mistake.

Browsers and their versions are listed at the top.*

Additional information:
ultimately, i've been able to handle the problem with the help of AJAX session 
refresh separate from .php image file, but i had to make considerable changes 
in the 
original code.

Thank you.

Original comment by free.goo...@gmail.com on 26 Jun 2009 at 6:42

GoogleCodeExporter commented 8 years ago
I think that is an PHP feature: the session data is stored at end of the script 
ejecution. 

You should use different session name for each captcha, for example:

$captcha->session_var = 'captcha_'.uniqid();

do you have a sample code with the problem?

Original comment by joserodr...@gmail.com on 29 Jun 2009 at 4:47

GoogleCodeExporter commented 8 years ago
I have inspected the problem more detailed and found out that it was due to 
image 
cache - session was rewritten but the image was the cached one.

So, the best was out was to:

1. Remove image source from html example: <img src="captcha/captcha.php" 
id="captcha"> -> <img id="captcha">
2. Load image via javascript instead: document.getElementById("captcha").src = 
"captcha/captcha.php?" + Math.random();

Thank you!

Original comment by free.goo...@gmail.com on 30 Jun 2009 at 9:41

GoogleCodeExporter commented 8 years ago
The PHP scripts send an Expires header that prevent this issue.

Your apache server has the mod_cache or mod_expires module active ????

Original comment by joserodr...@gmail.com on 2 Jul 2009 at 3:54

GoogleCodeExporter commented 8 years ago
No, none of them is installed.

Perhaps, browser issue.

Original comment by free.goo...@gmail.com on 3 Jul 2009 at 5:46

GoogleCodeExporter commented 8 years ago
no further information

Original comment by joserodr...@gmail.com on 13 May 2010 at 4:11

GoogleCodeExporter commented 8 years ago
If you have ySlow running in FF, the image is loaded twice and your code is not 
accepted by the captcha.

Original comment by MissSass...@googlemail.com on 14 Jun 2011 at 3:03