I am stomped with the following problem:
I have a script start.php and a second script proceed.php
Relevant (and working) sections of the code:
start.php
<?PHP
start_session() ;
// this string will later be used to check if
// proceed.php was invoked via the form below
$verif_str="abc defg";
$name_str="hijk lmn";
// Store these vars in the SESSION array.
$_SESSION['vstr']=$verif_str;
$_SESSION['nstr']=$name_str;
// output the form (in real case with correct html surrounding
// the form, doctype, header, body tags, all that)
echo"
<form action='proceed .php' method='POST'>
<input type='text' name='field_01' />
<input type='text' name='field_02' />
<input type='hidden' name='check' value='$verif_s tr' />
<input type='submit' />
</form>";
?>
proceed.php
<?PHP
start_session() ;
// read back session vars
$verif_str=$_SE SSION['vstr'];
$name_str=$_SES SION['nstr'];
// read back hidden form var and regular fields
$check_str=$_PO ST['check'];
$field01=$_POST['field01'];
$field02=$_POST['field02'];
// are these strings equal ? If not, stop processing.
if ($verif_str != $check_str)
exit ('Verification code incorrect');
// Strings match, so open logfile, exit if this fails.
$fp = @fopen('transac tion.log','a');
if ($fp===false)
exit ('Could not open file. Aborting.');
// write contents, for brevity additional error-checking is
// omitted here. This exists in the actual code.
fwrite($fp,"=== ===========\n") ;
fwrite($fp,"Ver ification string:".$verif _str."\n");
fwrite($fp,"Nam e string:".$name_ str."\n");
fwrite($fp,$fie ld01."\n");
fwrite($fp,$fie ld02."\n");
fclose($fp);
// rest of code, irrelevant to my issue
?>
The problem:
When I call the script start.php and submit the form data, 100 out of
100 'experiments' lead to a correct log entry being written. Both
strings $verif_str and $name_str contain the values assigned in start.php.
(For the record, I tried Konqueror, elinks and Firefox 1.5.0.5 for a
browser, on a Gentoo Linux machine. The acting server is a
Centos/Apache2.0.50/PHP4.3.4 combination)
However, if some/many of the OTHER users visiting the page fill out the
form, quite often, but not always, the session variables lose their
values in proceed.php. The form variables are properly transmitted though.
I have not been able to reproduce or explain this difference in
behaviour. yet I do believe I am making some mistake somewhere in my
code. I just fail to see it I guess.
(Please ignore the stupidity of what the code actually does and whether
that is good practice, the real case is somewhat more complicated and
makes more sense.)
Does anyone recognize this, see what's wrong and care to help me out?
Thanks a bunch in advance!!
Regards
Sh 9 2115
Schraalhans Keukenmeester wrote:
I am stomped with the following problem:
I have a script start.php and a second script proceed.php
Relevant (and working) sections of the code:
start.php
<?PHP
start_session() ;
// this string will later be used to check if
// proceed.php was invoked via the form below
$verif_str="abc defg";
$name_str="hijk lmn";
// Store these vars in the SESSION array.
$_SESSION['vstr']=$verif_str;
$_SESSION['nstr']=$name_str;
// output the form (in real case with correct html surrounding
// the form, doctype, header, body tags, all that)
echo"
<form action='proceed .php' method='POST'>
<input type='text' name='field_01' />
<input type='text' name='field_02' />
<input type='hidden' name='check' value='$verif_s tr' />
<input type='submit' />
</form>";
>>
proceed.php
<?PHP
start_session() ;
// read back session vars
$verif_str=$_SE SSION['vstr'];
$name_str=$_SES SION['nstr'];
// read back hidden form var and regular fields
$check_str=$_PO ST['check'];
$field01=$_POST['field01'];
$field02=$_POST['field02'];
// are these strings equal ? If not, stop processing.
if ($verif_str != $check_str)
exit ('Verification code incorrect');
// Strings match, so open logfile, exit if this fails.
$fp = @fopen('transac tion.log','a');
if ($fp===false)
exit ('Could not open file. Aborting.');
// write contents, for brevity additional error-checking is
// omitted here. This exists in the actual code.
fwrite($fp,"=== ===========\n") ;
fwrite($fp,"Ver ification string:".$verif _str."\n");
fwrite($fp,"Nam e string:".$name_ str."\n");
fwrite($fp,$fie ld01."\n");
fwrite($fp,$fie ld02."\n");
fclose($fp);
// rest of code, irrelevant to my issue
>>
The problem:
When I call the script start.php and submit the form data, 100 out of
100 'experiments' lead to a correct log entry being written. Both
strings $verif_str and $name_str contain the values assigned in
start.php.
(For the record, I tried Konqueror, elinks and Firefox 1.5.0.5 for a
browser, on a Gentoo Linux machine. The acting server is a
Centos/Apache2.0.50/PHP4.3.4 combination)
However, if some/many of the OTHER users visiting the page fill out
the form, quite often, but not always, the session variables lose
their values in proceed.php. The form variables are properly
transmitted though.
I have not been able to reproduce or explain this difference in
behaviour. yet I do believe I am making some mistake somewhere in my
code. I just fail to see it I guess.
(Please ignore the stupidity of what the code actually does and
whether that is good practice, the real case is somewhat more
complicated and makes more sense.)
Does anyone recognize this, see what's wrong and care to help me out?
Thanks a bunch in advance!!
I don't really see anything wrong with your code. Have you been able to
check with ths users experiencing problems:
- What value the $_SESSION variable was?
- Wether they've disabled cookies?
- What happens if you just test wether a session works for them at all atm?
Grtz,
--
Rik Wasmus
Schraalhans Keukenmeester wrote:
I am stomped with the following problem:
I have a script start.php and a second script proceed.php
Relevant (and working) sections of the code:
start.php
<?PHP
start_session() ;
[snap]
Errrm, read session_start where I said start_session. Pardon the glitch.
Sh.
Rik wrote:
Schraalhans Keukenmeester wrote:
>I am stomped with the following problem:
I have a script start.php and a second script proceed.php
Relevant (and working) sections of the code:
start.php
<?PHP start_session( ); // this string will later be used to check if // proceed.php was invoked via the form below $verif_str="ab cdefg"; $name_str="hij klmn"; // Store these vars in the SESSION array. $_SESSION['vstr']=$verif_str; $_SESSION['nstr']=$name_str; // output the form (in real case with correct html surrounding // the form, doctype, header, body tags, all that) echo" <form action='proceed .php' method='POST'> <input type='text' name='field_01' /> <input type='text' name='field_02' /> <input type='hidden' name='check' value='$verif_s tr' /> <input type='submit' /> </form>"; proceed.php
<?PHP start_session( ); // read back session vars $verif_str=$_S ESSION['vstr']; $name_str=$_SE SSION['nstr']; // read back hidden form var and regular fields $check_str=$_P OST['check']; $field01=$_POS T['field01']; $field02=$_POS T['field02']; // are these strings equal ? If not, stop processing. if ($verif_str != $check_str) exit ('Verification code incorrect'); // Strings match, so open logfile, exit if this fails. $fp = @fopen('transac tion.log','a'); if ($fp===false) exit ('Could not open file. Aborting.'); // write contents, for brevity additional error-checking is // omitted here. This exists in the actual code. fwrite($fp,"== ============\n" ); fwrite($fp,"Ve rification string:".$verif _str."\n"); fwrite($fp,"Na me string:".$name_ str."\n"); fwrite($fp,$fi eld01."\n"); fwrite($fp,$fi eld02."\n"); fclose($fp); // rest of code, irrelevant to my issue The problem:
[snip]
I don't really see anything wrong with your code. Have you been able to
check with ths users experiencing problems:
- What value the $_SESSION variable was?
- Wether they've disabled cookies?
- What happens if you just test wether a session works for them at all atm?
1. I have (alas) not recorded the session variable itself in the logs
2 I have not been able to check (sofar) whether or not these users have
cookies disabled/enabled. I gather from your question cookies are a MUST
with sessions? No alternatives? At least one of them (them being the
users, not the sessions) is imho way too ignorant to even be able to
disable cookies let alone know why she would/should, leading me to
believe she has everything enabled and wide open on her box. Is it
feasible some popular firewall-like thingy blocks cookies?
3. The problem seems to recur every now and then. Most -if not all- HAVE
been able to use the form properly in the past, just suddenly they bump
into trouble, and once they do, each consecutive run immediately
following their first failed attempt shows the same loss of data.
All form data is utterly standard, just alphanumerical, no weirdly
formatted or otherwise dubious/suspect entries.
(In fact we are talking about a captcha script, displaying an image of 5
alphanumeric chars, the other half of the 'key' being parsed via the
session, the key itself via the form, and then reassembled and checked
in the proceed script)
Thanks sofar Rik! How rude would we be if we continued this in Dutch ? GRIN.
Sh.
Schraalhans Keukenmeester wrote:
Rik wrote:
>I don't really see anything wrong with your code. Have you been able to check with ths users experiencing problems: - What value the $_SESSION variable was? - Wether they've disabled cookies? - What happens if you just test wether a session works for them at all atm?
1. I have (alas) not recorded the session variable itself in the logs
Too bad, it seems to me a problem with continuing a session.
2 I have not been able to check (sofar) whether or not these users
have cookies disabled/enabled. I gather from your question cookies
are a MUST with sessions? No alternatives? At least one of them (them
being the
users, not the sessions) is imho way too ignorant to even be able to
disable cookies let alone know why she would/should, leading me to
believe she has everything enabled and wide open on her box. Is it
feasible some popular firewall-like thingy blocks cookies?
Alternatives for cookies is offcourse a POST/GET variable. Since you're
using a form though, be sure you've configured PHP correctly to 'magically'
add the POST/GET variable so he user can continue his session and doesn't
start a new one over and over again.
3. The problem seems to recur every now and then. Most -if not all-
HAVE been able to use the form properly in the past, just suddenly
they bump
into trouble, and once they do, each consecutive run immediately
following their first failed attempt shows the same loss of data.
What if you unset($_SESSION );session_destr oy(); after a failure and then
let them retry?
All form data is utterly standard, just alphanumerical, no weirdly
formatted or otherwise dubious/suspect entries.
Well, then that probably isn't the problem.
Could you enable some kind of logging, to check wether the users
experiencing problems can continue sessions?
Thanks sofar Rik! How rude would we be if we continued this in Dutch
Verschrikkelijk asociaal ja ;)
--
Grtz,
Rik Wasmus
Schraalhans Keukenmeester wrote:
[for php code see original post, snipped]
Rik wrote:
>Schraalhans Keukenmeester wrote:
>I don't really see anything wrong with your code. Have you been able to check with ths users experiencing problems: - What value the $_SESSION variable was? - Wether they've disabled cookies? - What happens if you just test wether a session works for them at all atm?
Just something else that I think might perhaps be relevant:
The main page of the site I run this on is invoked by a URL:
Let's say http://www.this--domain.com, actually opening (framed): http://www.my--server.com/index.html
The scripts themselves only deal with relative paths, no URLs, all
scripts are on the same server under the same docroot.
Is it possible the redirect has something to do with this as well???
Sh.
Schraalhans Keukenmeester wrote:
Schraalhans Keukenmeester wrote:
[for php code see original post, snipped]
>>Rik wrote:
>>>Schraalhan s Keukenmeester wrote:
>>>I don't really see anything wrong with your code. Have you been able to check with ths users experiencing problems: - What value the $_SESSION variable was? - Wether they've disabled cookies? - What happens if you just test wether a session works for them at all atm?
Just something else that I think might perhaps be relevant:
The main page of the site I run this on is invoked by a URL:
Let's say http://www.this--domain.com, actually opening (framed): http://www.my--server.com/index.html
The scripts themselves only deal with relative paths, no URLs, all
scripts are on the same server under the same docroot.
Is it possible the redirect has something to do with this as well???
Sh.
Possible, but then it should fail more regularly and with more people.
Have those who are having the problem clear their cache and cookies. I
suspect that will help.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Rik wrote:
>Thanks sofar Rik! How rude would we be if we continued this in Dutch
Verschrikkelijk asociaal ja ;)
ach, valt wel mee. :P
Have you tried closing the session once you don't need to change it any
more? I don't remember exactly but I think the function is named
something like session_write_c lose().
This simple step solves most of the "random" issues with php's sessions
as it allows other scripts to read the same session file.
Nico wrote:
Have you tried closing the session once you don't need to change it any
more? I don't remember exactly but I think the function is named
something like session_write_c lose().
This simple step solves most of the "random" issues with php's sessions
as it allows other scripts to read the same session file.
Thanks for the pointers, I have 'expanded' the logging data set for now
and added the suggested function. Now let's wait and see how things go
from here. I'll report back how I fared.
Rgds
Sh This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: vivek |
last post by:
Do any of you guys have any idea what might be the reason for losing session
variables, i was working on a page where i had to stroe a array in a
session(trust me that was the only 'way' i could imagine doing it), and i am
losing the session variable, its just returning empty values...does any one
has any ideas?
|
by: Scott Lyon |
last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to
rewrite it) an application that is suddenly giving me grief.
The reason I say suddenly, is because we're in the process of transitioning
the server on which it runs from Microsoft Windows 2000 Server, to 2003
server (going from IIS 5 to IIS 6). This problem hasn't really occurred on
the 2000 server machine, but it's happening MUCH more on the new 2003 box
(not...
|
by: Al Jones |
last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate
group would you point me toward one that is.
Basically, I seem to be losing session data part way though preparing an
email from (possibly) three seperate forms.
the following code is the end of a routine which stashes data from the first
form
off to session variables and then redirects itself to the proper form /
procedure depending upon the state of two...
|
by: James |
last post by:
Session("UserName") is set when someone logs in. Get to a page that
displays a record where you can type a comment. The form has an onSubmit
event that calls a javascript function. That function sets a javascript
variable called beenChecked = true and then calls a PopUp window to spell
check the comment. When it's done spell checking, it calls the submit
method on the form tag of the opening window. The method evaluates that
it's...
|
by: Marc Rivait |
last post by:
Here is a very interesting scenario.
I have a simple test application that loads a page and sets a session
variable on the load event. On the first page there is a link to a second
page. The load event of the second page displays the value of the session
variable.
The problem is that when I use a W2k machine, this little test works
perfect. Session variable value is displayed on the second page. However,
when I use my XPPro...
| |
by: ACaunter |
last post by:
Hi all,
I'm wondering why I keep losing my session variables all the time. I've set
the timeout to be an hour, but for some reason randomly i keep losing
everything..
what could be causing this??
also, is there a way to automatically go back to the login page as soon as
the sessions have expired or are lost.
thanks
|
by: Jimmy Reds |
last post by:
Hi,
Sorry if this appears twice but I post through Google Groups and it had
a funny 5 minutes and didn't appear to post this message the first
time.
I am setting session variables on a page then doing a header/location
redirect to a second page however I am losing one of my session
variables. Not all of them, just one.
|
by: Jimmy Reds |
last post by:
Hi,
I am setting session variables on a page then doing a header/location
redirect to a second page however I am losing one of my session
variables. Not all of them, just one.
Here are some details/comments:
I am doing a session_start() on ALL of my pages, right at the top of
each page
|
by: Erik |
last post by:
I have an application that uses sessions variables a lot but one I publish
the application on the prod server these variables are lost. The application
is written i c# 2.0 and I've set the statServer timeout to 20 min in the the
web.config file. Any ideas why the variables are lost?
|
by: Geoff Berrow |
last post by:
I have a page containing a form. The page submits to itself and if the
data validates, stores the posted variables into a database and also
into a session. I then use header to redirect to another page which
fetches the variables from the session array and displays them.
All works fine on the Linux test server. However the production server
is Windoze running PHP 5. reg globals off I am intermittently losing
variables. from the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |