[SOLVED]storing session arrays design advice
Posted: Thu Sep 14, 2006 9:43 am
Hi,
My question is about storing large arrays and passing them between pages. A simple session array doesn't work because a user needs one array per tab/window he is looking at. Basically I need an equivalent to having one session_id for each tab/window.
To give a little more detail:
I am getting data from a mysql database and displaying it in a graph (jpgraph).
Once the graph is displayed, I have buttons to allow the user to zoom in, adjust scale/colors etc of graph. Because of the nature of the data, it is much more efficient to store the graph data in an array rather than requery it when these graph adjustments are made (the underlying data of course doesn't change).
The user can have as many of these graphs open in windows/tabs as he wishes, so one array needs to be stored for each window/tab.
I've hit upon 2 ways to do this so far each with its shortcomings.
1) fwrite the data to files (filename based on timestamps & session id), 1 file per graph - probably have a separate script to clean out files older than 3 days or so. The shortcoming here is that the deletion of files is not very clean, ideally I would like to delete them immediately when the window/tab graph is closed.
2) Create multiple session arrays on the fly as needed. The problem I see here is that all the arrays are written to the same file which doesn't seem to be a good approach - 1 file per graph seems to make more sense.
What would be the recommended/best practice way you would do this?
Thanks
My question is about storing large arrays and passing them between pages. A simple session array doesn't work because a user needs one array per tab/window he is looking at. Basically I need an equivalent to having one session_id for each tab/window.
To give a little more detail:
I am getting data from a mysql database and displaying it in a graph (jpgraph).
Once the graph is displayed, I have buttons to allow the user to zoom in, adjust scale/colors etc of graph. Because of the nature of the data, it is much more efficient to store the graph data in an array rather than requery it when these graph adjustments are made (the underlying data of course doesn't change).
The user can have as many of these graphs open in windows/tabs as he wishes, so one array needs to be stored for each window/tab.
I've hit upon 2 ways to do this so far each with its shortcomings.
1) fwrite the data to files (filename based on timestamps & session id), 1 file per graph - probably have a separate script to clean out files older than 3 days or so. The shortcoming here is that the deletion of files is not very clean, ideally I would like to delete them immediately when the window/tab graph is closed.
2) Create multiple session arrays on the fly as needed. The problem I see here is that all the arrays are written to the same file which doesn't seem to be a good approach - 1 file per graph seems to make more sense.
What would be the recommended/best practice way you would do this?
Thanks