Gossamer Forum
Home : General : Internet Technologies :

PHP: Delete Session Variables: By Admin

Quote Reply
PHP: Delete Session Variables: By Admin
Hi all,

DISCLAIMER: I've read through countless PHP manual pages and searched both PHPBuilder Community and Google for possible answers to the following issue, with no success.

I am trying to resolve a relatively complex issue for one of the projects I am working on....

Here is the scenario:

1) End-user/member logs in and we use SESSION variables to display customized "dynamic" content in "their" homepage.

2) Most fields in the user and profile tables are editable by the end-user/member, and I use the session_unregister() function and re-set session variables (session_start(), $_SESSION[''] = $newvalue;) with the new values entered by the user...this works fine.

3) Some fields can only be edited by the admin, but already set as SESSION vars to be used in the end-users/members custom homepage. The Admin edits some of these field, and of course, the end-user/member does not see the change since they are still logged in and the SESSION variable is set to the old value.

I've attempted to re-write our login logic that deletes out the "Persist Code" that is used to verify persist logins. This works okay, if the end-user/member closes their browser...but does not really log them off the system.

Of course, the easy answer is limit the number of SESSION vars set for the custom homepage and "hit" the database anytime someone accesses their custom homepage. But this is a huge load issue on the database (even with MySQL 4.0, co-located managed server).

So, my question is...Is there a method of deleting individual SESSION vars of the user account being edited by the Admin?
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] PHP: Delete Session Variables: By Admin In reply to
If I understand what you're asking, I don't believe it's possible. While I'm no expert at sessions in PHP, I'm pretty sure all of the functions available only work on the current session for the current user - so there's no way that I know of to delete or otherwise alter a session's variables on the admin side without using database queries or other server-side storage elements.

The only thought I have on reducing database load, is that perhaps there is a way to restructure the way the database queries are being performed to minimize the memory/processing involved. Perhaps you could have a temporary table that only holds rows of information on users who have had their info changed by the admin, and then that row gets deleted as soon as it is accessed by the user. At least you could keep the table lean and mean and under normal circumstances the home page would just have to do a quick check to see if the user's id is in that table. If not, use the current session info, if so, then update it. Just a thought - I know it doesn't really accomplish what you're looking for, but it might be a "better than nothing" option...

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] PHP: Delete Session Variables: By Admin In reply to
Thanks for your reply. Your points about session variables are well-taken.

However, even setting up "temp" tables would be added load on the database server. The main criterion for the website I am working on is to keep it as fast as possible (in terms of downloading). And while, yes, going to direct queries of tables in the database would be the most effective for the problem I am attempting to resolve, it will have an adverse affect on the download time (in terms of having to connect to the database on each access to the homepage).

I guess the rudimentary "fix" I've deployed in terms of deleting out the persistant login code in the user table when the admin edits the user record will have to do.
========================================
Buh Bye!

Cheers,
Me