Forum Moderators: coopster

Message Too Old, No Replies

Performance considerations when using session variables

I'm considering storing large chunks of data in session variables...

         

erikcw

2:49 am on Dec 31, 2004 (gmt 0)

10+ Year Member



Hi All,

I am writting an application, where data must be manipulated on one page, and then when the user/application is finished, post the data onto the next page of the application.

I'm considering putting the data (one large variable ~200k) into a session variable - but I am concerned about performance issues. What are the performance implications of using sessions for transporting large (or numerous) variables/arrays?

The other two models I'm considering are:
a) writing the data to a mysql db, and then accessing it on the next page.
b) writing the data into a hidden field in a second form on the the page (the first form is used for data manipulation), and posting it to the next page in the app.

What is the best (most efficient) way to tackle this?

Thanks!
Erik

coopster

1:57 pm on Dec 31, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP sessions are flat files stored on the server's file system. As far as storing sessions in a flat file versus a database? Your choice I guess. I have never measured performance in one versus the other myself.

I think the bigger issue to consider when maintaining state is the amount of information being pushed back and forth (bandwidth). If you have a large amount of information to store and won't need it again until more than one page down the process, then sessions are a good idea. If you are simply filling the information out on one screen and displaying it again on the next, there really is no need for the session to store the information.