Strange Sessions Issue
Moderator: General Moderators
Strange Sessions Issue
Hello,
I have two identical sites hosted with two different ISPs; one has login/logout issues, the other does not. The only difference is there is a PHP Conncetion file that points to the MySQL database at each hosting server. The databases are identical, same name, same tables, it was a copy.
The fully functional site was uploaed to the other hosting company server. I then changed the 4 connection variables on my connection PHP file; 1-MySQL DB server name, 2-database name, 3-user name, 4-password. Other than that, every line of code is identical between the sites. I even ran them through source code compare tools.
I am having various auto-logout issues. One example is that when I add to the shopping cart by clicking the add-to-cart button, I end up on the add-to-cart page as I should but I have a "your shopping cart is empty", and I am now logged out. My site requires the user to be logged in to buy.
Another example is when a new user registers they are auto-logged in. On one site this works fine, on the other site after registering they are directed to the login page indicating the auto-login failed.
I positive the code and databases are identical between the sites.
Has anyone ever experienced this before? Any suggestions? I was thinking that the PHP server settings are different on the two servers, so I created a PHP info page and compared them side by side, but I simply do not have the skills to know what setting could cause these session issues and the auto-logout. I have been on this for almost 2 weeks and simply have to get this done.
Thanks in advance
I have two identical sites hosted with two different ISPs; one has login/logout issues, the other does not. The only difference is there is a PHP Conncetion file that points to the MySQL database at each hosting server. The databases are identical, same name, same tables, it was a copy.
The fully functional site was uploaed to the other hosting company server. I then changed the 4 connection variables on my connection PHP file; 1-MySQL DB server name, 2-database name, 3-user name, 4-password. Other than that, every line of code is identical between the sites. I even ran them through source code compare tools.
I am having various auto-logout issues. One example is that when I add to the shopping cart by clicking the add-to-cart button, I end up on the add-to-cart page as I should but I have a "your shopping cart is empty", and I am now logged out. My site requires the user to be logged in to buy.
Another example is when a new user registers they are auto-logged in. On one site this works fine, on the other site after registering they are directed to the login page indicating the auto-login failed.
I positive the code and databases are identical between the sites.
Has anyone ever experienced this before? Any suggestions? I was thinking that the PHP server settings are different on the two servers, so I created a PHP info page and compared them side by side, but I simply do not have the skills to know what setting could cause these session issues and the auto-logout. I have been on this for almost 2 weeks and simply have to get this done.
Thanks in advance
Hello and thanks for the response. I am not clear on why the cookie would work on one domain but not the other. The code is identical on both sites, just different servers and ISPs. Cookies popped in my mind as a possibility because I know they are required for logging in. I just don't understand what would allow it to work on one but not the other.
I added a page on the working site and also one on the non-working site to display the PHP Info. The working site is http://www.title-insurance-search.com and the site with identical code that does not work and is hosted at a diferent ISP is http://www.appraiser-search.com. In the lower middle of each home page to the right of the "Sign Up Now" button there is a "go" link. Clicking on that displays the PHP Info page.
I added a page on the working site and also one on the non-working site to display the PHP Info. The working site is http://www.title-insurance-search.com and the site with identical code that does not work and is hosted at a diferent ISP is http://www.appraiser-search.com. In the lower middle of each home page to the right of the "Sign Up Now" button there is a "go" link. Clicking on that displays the PHP Info page.
Yes I did.. after 3 weeks of 12 hours days. It turned out to be a PHP server setting.
On the server and site that worked at midphase.com, the following PHP setting existed:
output_buffering = on
On the other 7 sites, all wth the same session issues, all on different ISPs and servers, they had it this way:
output_buffering = no value.
I had one of the ISPs change the setting, which they did with no poblem, and bam, the site worked liked a charm. I then emailed the other ISPs and most would not change the setting, and told me I had to use .htaccess file in the root directory of my site. You may already know this, but you can use the .htaccess text file to add directives to change settings locally, that is, just for your site.
If you place an .htaccess file in your root directory with the followling line, it will fix the problem I had:
php_value output_buffering 4096
On the server and site that worked at midphase.com, the following PHP setting existed:
output_buffering = on
On the other 7 sites, all wth the same session issues, all on different ISPs and servers, they had it this way:
output_buffering = no value.
I had one of the ISPs change the setting, which they did with no poblem, and bam, the site worked liked a charm. I then emailed the other ISPs and most would not change the setting, and told me I had to use .htaccess file in the root directory of my site. You may already know this, but you can use the .htaccess text file to add directives to change settings locally, that is, just for your site.
If you place an .htaccess file in your root directory with the followling line, it will fix the problem I had:
php_value output_buffering 4096
Just checked mine. Already set at no value.
My problem is I'm loosing the session value very quickly.
I test by inserting records to a database after I log in. I get about 4 done before it shows that I am logged off and have to log back in. It's a pain.
The more I dig into this the stranger it is. If I run the FireFox browser, I have no problem losing the session variable. In fact it works perfectly.
The problem is only while running IE6
My problem is I'm loosing the session value very quickly.
I test by inserting records to a database after I log in. I get about 4 done before it shows that I am logged off and have to log back in. It's a pain.
The more I dig into this the stranger it is. If I run the FireFox browser, I have no problem losing the session variable. In fact it works perfectly.
The problem is only while running IE6
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
It needs to be set to "on", not "no value". All of the servers that had "no value" did not work for me.
The .htaccess file with setting the value to "4096" did the trick for me.
I was able to go through a few screens OK, but most of my problems were all my redirects. As soon as I started with redirects triggered by buttons, the problems started.
The .htaccess file with setting the value to "4096" did the trick for me.
I was able to go through a few screens OK, but most of my problems were all my redirects. As soon as I started with redirects triggered by buttons, the problems started.
I found on another site that the following code that is supposed to work.
(from file insert.php)
session_write_close();
header( "location: /thankyou.php");
exit;
The thankyou.php page has no code in it other than displaying the Clubname.
The redirect may work a couple of times and then doesn't. It is almost always 4 times and then the session loses the value and Clubname is blank.
The thankyou.php has a link that goes back to insert.php
Insert.php displays a form and writes the records to mysql database table.
very simple stuff.
(from file insert.php)
session_write_close();
header( "location: /thankyou.php");
exit;
The thankyou.php page has no code in it other than displaying the Clubname.
The redirect may work a couple of times and then doesn't. It is almost always 4 times and then the session loses the value and Clubname is blank.
The thankyou.php has a link that goes back to insert.php
Insert.php displays a form and writes the records to mysql database table.
very simple stuff.
if your problem hasn't been solved.
1. make sure you don't redirect (without the sessionid at least)
2. turn on all error reporting, if output_buffering=on helps, then you are doing something wrong causing late header modifications which are discarded.
3. are you switching in the hierachy (up and down in folders) that might cause some problems, as certain security checks might fail auotmatically discarding sessions and such.
is it always on the same side or on different?
1. make sure you don't redirect (without the sessionid at least)
2. turn on all error reporting, if output_buffering=on helps, then you are doing something wrong causing late header modifications which are discarded.
3. are you switching in the hierachy (up and down in folders) that might cause some problems, as certain security checks might fail auotmatically discarding sessions and such.
is it always on the same side or on different?