tags:

views:

2708

answers:

6

Hi, I have a PHP form (mortgage app) that is about 400 fields, traffic on the site will be low.

What is the ideal Session size for 400 fields going into a MySQL db?

In PHP.ini what do I set?

Anything I should set that I am missing?

-Jason

A: 

Are you maintaining sessions through the MySQL db?

Darryl Hein
A: 

No I am not

I submit the form and collect the posted fields and lodge them in the DB

A: 

Well, personally I have had very large sessions before with very little problems. Probably the largest size I've had before is ~10MB. It's not optimal, but I haven't had a problem with slow scripts even with that size. I wouldn't worry about sessions getting to large, but I would try to keep it under control. My theory is, if keeping it in the session makes it much faster than quering the database every time (such as in the case of a search) then I go for it.

Darryl Hein
A: 

What is the best way to set that? I know in PHP ini, but is there more than one way?

session.size = ??

+1  A: 

There is no limit to the size of the session, BUT there is a limit to the memory PHP can take: http://ca.php.net/manual/en/ini.core.php#ini.memory-limit

Darryl Hein
A: 

It's not advisable to store a lot of data in a session. As others have noted, it's not a idea to duplicate data from a database. Even if you really need some sort of caching mechanism, you wouldn't store the data in a session. The problem is that PHP rewrites the session data for every request. And as we all know writing to disk is a rather slow operation.

If you really need to do it, serialize the array and store it in a separate file.

If you need that bunch of serialized data only 1 in 10 pages, you only unpack it once in 10 pages. Session is of course packing/unpacking for every request.

Rajib