rebelo wrote:Hi Halojoy,
I am certainly in agreement with the usefulness of SESSION variables, however they are not appropriate for this usage. It is necessary to call the user related data from the database on every page (whether it's all at once in an array or as needed through individual query functions), because if an admin makes a change to a user's account (such as suspending their account or changing their access permissions), these changes need to take effect immediately so that users cannot "ride the session" and potentially get around access limitations which may have been set in place while they were logged in.
I see.
If we do not want to have current work data
in database table storage file
and not in session temp file
and being afraid being short of working system memory
than
we have not much options left.
It is perfectly easy to store any two or more dimensions arrays
in Flat Text files in your harddrive.
If was a possiblilty to store in memory, this would be much better
and the method to use if only possible!,
because ordinary harddrives are slow compared with any sort of memory
(50 MHz to 1000 MHz, a factor like 10-20!)
and as database MySQL or Flat or whatever also uses files,
things can not happen faster than harddrive
can read and transfer data to php.exe or any other program.
Anyway to store in a temp workfile in drive
makes data solid, whatever page you are on,
and does not care if you are in a session or not - it is like having data in database.
But this way data is a bit closer to you - with no database middle-hands - go-betweens.
You have total control what is done with your data array.
Here is way I sometimes use for store array variables in file,
for easy recovering and working with data.
Even if you probably knows this very well,
we have many other readers and eager php code learners
who could have good use for this method.
<?php
// Write '$data' array to a file "tempfile.data".
// serialize array and write binary
$fp=fopen('tempfile.data','wb');
fwrite($fp,serialize($data));
fclose($fp);
// Read Back '$data' array from file "tempfile.data".
// read binary and unserialized into array '$data'
$fp=fopen('tempfile.data','rb');
$data = unserialize(fread($fp,filesize('tempfile.data')));
fclose($fp);
?>
The above fwrite does not use my file locking function for flat files.
But if this is an issue, I have posted the code of lock file while write elsewhere at forum.
A few minutes of search phpbuilder forum would give that function code
to anyone in need.
halojoy - one dimesional man with many ideas
🙂