Session
by RameshKumar[ Edit ] 2007-09-24 09:54:42
Hi friends,
Hope this will be an interesting one.
The captcha image is generated, using random numbers. The random number is passed to a session variable and the image is created using that session value.
Issue:
This script works fine when it is used within the forms or in other webpages. The issue arises only when it is used with iframe.
The captcha image is used as a image source.
<form name=formname method=post action='<?php echo($PHP_SELF); ?>'>
<img src='cap-img.php'>
The form is validated if the value of image-source and user-entry or equal, the img value should get changed when the the page is refreshed or when the user-entry is wrong. but it does not do so. The image-source displays the same value, but when i print the session-variable it prints different value the same value does not works on the image.
Can you guess wt the issue is??
The issue is with the cache, the image gets value form the cache and prints the same old session value and not the original session value.
Solution::
Make the each request with different argument, the following code will make it more clear.
$sesid = $_GET['sesid']; //get session id when the form is submited
if($sesid != ""){
session_id($sesid);
}
session_start();
$sesid = "?sesid=".session_id();
<form name=sdmail method=post action='<?php echo($sesid); ?>'>
// request made with diferent argument
<img src='cap-img.php<?php echo "$sesid"."&tim=".time(); ?>'>