Running:
Microsoft SBS 2003 w/ IIS 6.0
PHP 5.21 ISAPI
An ecommerce site I had running at a web host on some incarnation of PHP4 has now been moved to my own in-house web server. Both were running IIS, but I am on 6 and they were on 5 something. Also, PHP changed from 4 to 5.21. My problem is, sessions sometimes work but mostly don't. Nothing that is repeatable. I have been scouring the net for weeks and have everything set up right. PHP is installed in C:\php, and the "Network Service" account has read/execute access to it. Sessions are in C:\php\sessions and everything is configured right in php.ini. "Network Service" has full control of the sessions folder. All the ISAPI extensions, web services, etc.. are set up properly in IIS. Basically, everything works perfectly when the session decides to work.
Let me go into that a little deeper. A session cookie is always created for the browser whenever there isn't one detected. I can look at it in my browsers cache and find it in the C:\php\sessions folder. So sessions are actually created the right way. The problem is, when I add something to my shopping cart it most of the time refreshes the page and the cart still says it is empty. If I clear my browsers cache, delete everything from the C:\php\sessions folder on the server, then most of the time I can get everything to work...things add to the cart beautifully. If a person completes an order all the way through to the checkout process however, when they are dumped back into the site with a freshly emptied cart, it will never work. Not for them nor most others visiting the site.
I use all $_SESSION vars not the old $HTTP_SESSION_VARS variables..I had to convert all those a long time ago. I have already tried playing with php.ini until I am exhausted...just to get it to work, I have turned on globals, etc.. I also have @session_start() on every page.
I am leaning towards blaming this on some garbage collection or some bad relationship between PHP 5.21 and IIS 6.0. I have trouble blaming my code since it has worked for many years and still works sometimes now. When code is bad it is usually predicatbly bad whereas this seems like a container issue instead because of its unpredictability.
I am at the end of my rope! Any help would be appreciated...What is the value of session.gc_maxlifetime? (If it's too small, session data may be getting "garbage collected" too soon.)the session.gc_maxlifetime is set to 1440. I checked that at one point of my troubleshooting.. Once something sticks to the $_SESSION and things will go into the cart, I can shop around the site for a long time with no problems and everything works fine.. It is just completely random when it wants to work.
EDIT-- Actually, once in awhile you do lose the data in your session even after it has started working...There are a couple of threads on this sort of problem on MSDN, what browser are you using
This one (<!-- m --><a class="postlink" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=926622&SiteID=1">http://forums.microsoft.com/MSDN/ShowPo ... 2&SiteID=1</a><!-- m -->) is related to IIS/PHP sessions and IE7 deleting the session cookie when the user returns to the original page.
This one (<!-- m --><a class="postlink" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=867126&SiteID=1">http://forums.microsoft.com/MSDN/ShowPo ... 6&SiteID=1</a><!-- m -->) is the same problem with IE7 but involves the use of javascript in the <head>, which I guess your cart probably has somewhere.
Lots of people with php session problems and as one poster sez "How Microsoft didn't notice this in 2 years I don't know. Shameful"
If it is not an IE7 bug then search msdn for IIS and SBS issues, bound to be a mickeysoft problem as usual.
Personally I recommend you drop IIS and use Apache.I use IE, Opera, & Firefox...test with all three browsers. As far as IIS goes, I know I could switch to Apache and problem solved, but I have some heavy ASP sites as well and I really don't want to take that approach. I am nearly at the point of making this works (I hope)...so I am not ready to quit just yet. I am looking for any help on a fix for this at this point still, not ready to jump ship.
Another note that may help diagnose things...I constantly get thid in the PHP error log...
PHP Warning: Unknown: 3 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
But every page frees its result sets at the bottom of the code... This wouldn't have anything to do with the problem would it?PHP Warning: Unknown: 3 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
But every page frees its result sets at the bottom of the code... This wouldn't have anything to do with the problem would it?
Well all result sets should be freed as soon as any script finishes, likewise if the connection is closed before a script ends. Whether it relates to this session problem or not, it is a problem in itself, or indicates one. I got no experience of php on IIS so I can't suggest where to start looking. I would suggest again that you try the mdsn forums for this.
Microsoft SBS 2003 w/ IIS 6.0
PHP 5.21 ISAPI
An ecommerce site I had running at a web host on some incarnation of PHP4 has now been moved to my own in-house web server. Both were running IIS, but I am on 6 and they were on 5 something. Also, PHP changed from 4 to 5.21. My problem is, sessions sometimes work but mostly don't. Nothing that is repeatable. I have been scouring the net for weeks and have everything set up right. PHP is installed in C:\php, and the "Network Service" account has read/execute access to it. Sessions are in C:\php\sessions and everything is configured right in php.ini. "Network Service" has full control of the sessions folder. All the ISAPI extensions, web services, etc.. are set up properly in IIS. Basically, everything works perfectly when the session decides to work.
Let me go into that a little deeper. A session cookie is always created for the browser whenever there isn't one detected. I can look at it in my browsers cache and find it in the C:\php\sessions folder. So sessions are actually created the right way. The problem is, when I add something to my shopping cart it most of the time refreshes the page and the cart still says it is empty. If I clear my browsers cache, delete everything from the C:\php\sessions folder on the server, then most of the time I can get everything to work...things add to the cart beautifully. If a person completes an order all the way through to the checkout process however, when they are dumped back into the site with a freshly emptied cart, it will never work. Not for them nor most others visiting the site.
I use all $_SESSION vars not the old $HTTP_SESSION_VARS variables..I had to convert all those a long time ago. I have already tried playing with php.ini until I am exhausted...just to get it to work, I have turned on globals, etc.. I also have @session_start() on every page.
I am leaning towards blaming this on some garbage collection or some bad relationship between PHP 5.21 and IIS 6.0. I have trouble blaming my code since it has worked for many years and still works sometimes now. When code is bad it is usually predicatbly bad whereas this seems like a container issue instead because of its unpredictability.
I am at the end of my rope! Any help would be appreciated...What is the value of session.gc_maxlifetime? (If it's too small, session data may be getting "garbage collected" too soon.)the session.gc_maxlifetime is set to 1440. I checked that at one point of my troubleshooting.. Once something sticks to the $_SESSION and things will go into the cart, I can shop around the site for a long time with no problems and everything works fine.. It is just completely random when it wants to work.
EDIT-- Actually, once in awhile you do lose the data in your session even after it has started working...There are a couple of threads on this sort of problem on MSDN, what browser are you using
This one (<!-- m --><a class="postlink" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=926622&SiteID=1">http://forums.microsoft.com/MSDN/ShowPo ... 2&SiteID=1</a><!-- m -->) is related to IIS/PHP sessions and IE7 deleting the session cookie when the user returns to the original page.
This one (<!-- m --><a class="postlink" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=867126&SiteID=1">http://forums.microsoft.com/MSDN/ShowPo ... 6&SiteID=1</a><!-- m -->) is the same problem with IE7 but involves the use of javascript in the <head>, which I guess your cart probably has somewhere.
Lots of people with php session problems and as one poster sez "How Microsoft didn't notice this in 2 years I don't know. Shameful"
If it is not an IE7 bug then search msdn for IIS and SBS issues, bound to be a mickeysoft problem as usual.
Personally I recommend you drop IIS and use Apache.I use IE, Opera, & Firefox...test with all three browsers. As far as IIS goes, I know I could switch to Apache and problem solved, but I have some heavy ASP sites as well and I really don't want to take that approach. I am nearly at the point of making this works (I hope)...so I am not ready to quit just yet. I am looking for any help on a fix for this at this point still, not ready to jump ship.
Another note that may help diagnose things...I constantly get thid in the PHP error log...
PHP Warning: Unknown: 3 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
But every page frees its result sets at the bottom of the code... This wouldn't have anything to do with the problem would it?PHP Warning: Unknown: 3 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
But every page frees its result sets at the bottom of the code... This wouldn't have anything to do with the problem would it?
Well all result sets should be freed as soon as any script finishes, likewise if the connection is closed before a script ends. Whether it relates to this session problem or not, it is a problem in itself, or indicates one. I got no experience of php on IIS so I can't suggest where to start looking. I would suggest again that you try the mdsn forums for this.