Jump to content

I need a PHP Sessions expert


dokrongly

Recommended Posts

There is a problem that kicks my user off the session (I think).  The user does not get an error message - the webpage looks the same to them, but I know there's something wrong because the user's name is supposed to display at the top of the page and it will disappear at random.  Anything new they try to add to the database after their name disappears will be inserted, but it will be inserted with a userID foreign key of 0 instead of the actual user's userID.  If they try to select or update anything that requires their userID, they will simply get no records returned (but the webpage is otherwise displaying properly).

 

If I go into the C-Panel/MyPHPAdmin management screen and work directly in the database until the error occurs, I do get an error message -- it is pasted below.

 

#0  PMA_sendHeaderLocation(http://www.meetingsetter.com:2082/3rdparty/phpMyAdmin/sql.php?db=meetings_MeetingSetter&table=tblUsers&token=e4e0117605a3ba48255dde1a8e56626c&sql_query=SELECT+%2A++FROM+%60tblUsers%60+WHERE+%60UserOfcCtr%60+%3D+0&message=MySQL+returned+an+empty+result+set+%28i.e.+zero+rows%29.+%28Query+took+0.0004+sec%29) called at [/usr/local/cpanel/base/3rdparty/phpMyAdmin/sql.php:620]

#1  require(/usr/local/cpanel/base/3rdparty/phpMyAdmin/sql.php) called at [/usr/local/cpanel/base/3rdparty/phpMyAdmin/tbl_replace.php:372]

 

Fatal error: PMA_sendHeaderLocation called when headers are already sent! in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/common.lib.php on line 655

 

General info about my website:

I have a PHP website with users logged in and session established and accessed on every page.  Totally random problem - happens to every user, no matter what machine they're sitting at; happens on various pages; happens in response to various interaction with the database, e.g. it happens in response to inserts, updates, and simple selects.  I can't find a pattern no matter how hard I try.  Sometimes the error occurs very early in the session during the 2nd or 3rd interaction with the database but sometimes it happens later during the 30th interaction with the database.  But there has never been a live session yet that didn't have the problem.  (the problem never happens in my local Apache development environment, only live).

 

Here are as many parameters of my site as I can think of that you might need.  Let me know if there's anything else you need.

Shared hosting (e.g. not a dedicated IP address)

PHP version 5.2.5

Apache version 2.0.63

MySQL version 5.0.45-community-log

 

My web hosting vendor says it is a PHP problem and they won't help me.  Is there anyone out there who knows what is causing this problem & how I can fix it.  I'm going to lose my client if I can't overcome this problem, and I'm feeling desparate.

Link to comment
https://forums.phpfreaks.com/topic/111264-i-need-a-php-sessions-expert/
Share on other sites

well, I suppose that's true - but it's not my code that's throwing this error.  it's the web host's cpanel code that's throwing this error.  so I guess the fact that I included that error code example wasn't very helpful, was it.

 

my web pages don't throw any error at all.  when you read my description of what's happening does it sound like an issue with the PHP session?  or does it sound like something else.  I really don't think it's a problem with the database because like I said the user can still query the database as long as the query doesn't depend upon their userID, and they can insert new records into the database but their own userID will not be used as the foreign key.  so it's not the database connection that's the problem.

 

but the user's name that I display at the top of the page is driven by the Session variable "UserID".  that's why I thought perhaps the session is breaking.  since I don't have control over the php ini that controls session length etc I'm not sure what those settings are. 

 

even if someone can't help me fix this directly, can you give me some specific questions I can take to my web host vendor?  right now they just say it's a PHP problem and they won't even talk to me.

I dont do anything fansy with the header() command, but i have never had a problem with sessions either. The very first thing in any of my code is this:

<?php
// Include Files nessary to complete any tasks assigned.		
include("includes/generalsettings.php");
include("includes/functions.php");
?>

 

generalsettings contains information about the database to use and each of the session fields.  The applicable part looks like:

 

<?php
Session_Start();
Session_Register("user_id");
Session_Register("user_name");
Session_Register("user_password");
Session_Register("user_email");
?>

 

In my experience the session will pull the last value set to it from any other page, so each of these variables are only set in the log in function and i can use them in any other page so long as the session is initiated on that page.

Thanks, ThunderAI.  I am already executing session_start() at the beginning of each page and grabbing values from one or more session variables depending on the needs of that particular page.  but it's good to have it confirmed.

 

here's another question for anyone who cares to reply -- is there a way I can force an error message to echo to the screen?  for instance, in my local development environment I can set one of the configurations in PHP to throw errors in a more sensitive fashion than I can do on the live web hosting environment (since, as I said, I don't have access to the PHP ini file on my host's server).  but is there something at the code level I can do to provide an error message that will show me what's wrong?

 

I believe my main problem right now is since there's no error message I can't figure out what the error is in the first place.  know what I mean?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.