Hi, in my php.ini file I have appended the Harry Fuecks mysql session handler script to store sessions in my database. Sorry but I can no longer find an example of this script on the net, I have looked. The script connects to mysql with a user name of ‘sessions_user’ and a password of ‘123’. It connects to the database ‘site_sessions’ and stores php sessions in the table ‘php_sessions’. This is the only table in this particular database. The usernames, passwords and database/tables are just examples. Grants are put on ‘sessions_user’ to only have SELECT, UPDATE, INSERT and DELETE privileges on the ‘site_sessions’ database and none other.
On my regular php files I have an include file that connects to the database and retrieves all the site’s content and articles. The scripts that require database access connect to mysql with a user name of ‘content_user’ and a password of ‘ABC’. They connect to the database ‘site_content’ and access various tables within that database. A link identifier is used when selecting the database. Grants are put on the ‘content_user’ to only have SELECT, UPDATE and INSERT privileges on the ‘site_content’ database and none other.
Now the problem:
When running a query within a regular script this works:
SELECT * FROM tbl_articles
But when I issue the session_start() function on the scripts that require sessions, the above query doesn’t work. I get an error along the lines of " The table ‘tbl_articles’ cannot be found in the database ‘site_sessions’. What the frig? I’m connected to the database ‘site_content’ aren’t I?
If I change ‘FROM tbl_articles’ to 'FROM site_content.tbl_articles’, the query works as per it did when the call to session_start() wasn’t present. What could be going on here? I’m a little concerned that all the scripts with session_Start() in them are connecting to mysql and running queries under the user name ‘session_user’ and ‘123’ instead of ‘content_user’ and ‘ABC’. However if this was the case wouldn’t I be getting errors about that user not having GRANT privileges on the ‘site_content’ database?
I’m a little confused as to what’s up with this. Is there a definitive way of finding out what user is actually carrying out DB queries on those scripts that have a call to session_start()?