Session Globals

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Quick Question:

How many $_SESSION['xyz'] can you have set in PHP (one for the name, username, this, that, the other thing, and their dog and a hundred more)? Is there a limit? I've been looking all over for an answer, but I can't find one. Is the limit what your web server can handle? Or what the client allows?

Thanks

He has: 1,380 posts

Joined: Feb 2002

I'm not sure, but I would bet that you reach some sort of limit on the user end before the server side. The reason I say this is because, from what I know, the PHP session stores the info in a cookie of some sort, with references to the server... but it keeps some (if not all) of the data local somehow so you don't have to access it directly.

At least that's how I think it works... Sessions built on top of Cookies.

And I think that if that's true, it gives you your answer.... the user's computer/browser sets the limits.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Only the session id is stored on the user's computer. All the other data is stored on the server.

The only limit I'm aware of is running out of memory. Other than that, you shouldn't have a problem.

He has: 1,758 posts

Joined: Jul 2002

If all else fails there's nothing to stop you assigning an array as the value for the session...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.