A quickie - field size of php session id

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

What field size should I use to record a session id in a db?

I use session_id() to generate it but I've noticed ones of different  
sizes (character lengths) when testing.

Is there is min / max size?




Re: A quickie - field size of php session id

On Fri, 02 Sep 2005 22:22:27 +0000, toedipper wrote:

Quoted text here. Click to load it

I use PHPSESSID VARCHAR2(2048). I never had any problems.


Re: A quickie - field size of php session id

If you're using PHP 5, this is largely determined by the php.ini
settings session.hash_function and session.hash_bits_per_character
(unless you've overriden these somewhere else).

With the default of md5 and 4, you would get a 32-character hex string
(128 bits / 4).  When using sha1, you'll get a 40-character hex string
(160 bits / 4).

The cool thing about that is the fact that the session id's are exactly
the same length every time -- 128-bits for example.  So, if you wanted
to, you could probably make the column a fixed-length binary field
that's exactly the right length.

Site Timeline