blitzen
12-12-2011, 08:20 PM
Hi,
I'm pondering the best way for a 1-page checkout using PHP and AJAX, and I have a few questions about cookies and session variables.
Variable values will change on the fly without reloading the page (I hope I can avoid reloading the page) as the customer proceeds through steps in checkout.
I have an AJAX call to return values of php session variables. This seems to run much more slowly than javascript reading cookies. Thus, I'd prefer to store information in cookies.
However, there is sensitive information and long values that cannot be stored in a cookie. Thus, I'd like to use php session variables when necessary.
The php_value session.auto_start "on" is in htaccess and is working.
1. Javascript can write a cookie or change a cookie value without reloading the page.
Q. If that cookie changes without a page load, will a javascript function that is executed later read the new cookie value?
2. Javascript changed the value of a cookie without a page reload.
A php script is executed via AJAX.
Will the called php script
a) Read the original cookie value when the "html" page was initially loaded?
b) Or, get the new value when the php script (that is called by AJAX) is executed? Get the new value set by the Javascript?
3. The php file that was called by AJAX changed a cookie value. Will javascript running later read the new value?
Now, the same for PHP Session variables.
4. A php script that was called by AJAX changed a session variable.
If I do another AJAX call to a second php script, will the second php script read the new or old session value?
If this is browser-dependent, I'm sunk.
I hope this makes sense.
Thanks!
I'm pondering the best way for a 1-page checkout using PHP and AJAX, and I have a few questions about cookies and session variables.
Variable values will change on the fly without reloading the page (I hope I can avoid reloading the page) as the customer proceeds through steps in checkout.
I have an AJAX call to return values of php session variables. This seems to run much more slowly than javascript reading cookies. Thus, I'd prefer to store information in cookies.
However, there is sensitive information and long values that cannot be stored in a cookie. Thus, I'd like to use php session variables when necessary.
The php_value session.auto_start "on" is in htaccess and is working.
1. Javascript can write a cookie or change a cookie value without reloading the page.
Q. If that cookie changes without a page load, will a javascript function that is executed later read the new cookie value?
2. Javascript changed the value of a cookie without a page reload.
A php script is executed via AJAX.
Will the called php script
a) Read the original cookie value when the "html" page was initially loaded?
b) Or, get the new value when the php script (that is called by AJAX) is executed? Get the new value set by the Javascript?
3. The php file that was called by AJAX changed a cookie value. Will javascript running later read the new value?
Now, the same for PHP Session variables.
4. A php script that was called by AJAX changed a session variable.
If I do another AJAX call to a second php script, will the second php script read the new or old session value?
If this is browser-dependent, I'm sunk.
I hope this makes sense.
Thanks!