You need to call start_session before accessing $_SESSION variables UNLESS
you have PHP configured to automatically start_session (which is off by

You need to start_sesion so that scripts that don't need $_SESSION don't go
through the overhead of starting session.


-----Original Message-----
From: Sascha Cunz [mailto:Sascha@;] 
Sent: Tuesday, October 29, 2002 2:15 PM
Subject: Re: [PHP] Re: POST-ing or GET-ing an array


> I disagree that serialize/unserialize is the way to go, unless you're
> absolutely completely sure that there will only be a relatively small
> number of things in the array.  As somebody mentioned briefly, the get
> request is limited to a certain number of bytes, and the string
> representing your serialized array could easily get too large to send on a
> get request.
> imho the best option is to use the session, which somebody already
> mentioned but didn't really elaborate...
> $_SESSION['my_array'] = $my_array;

Exactly. But just to mention it at this point: if you have script-output 
(echo, print, print_r etc.) before any operation on $_SESSION, you should 
call start_session() at the start of the script. (I don't know if recent 
versions of PHP still _need_ this)

> and on next_page (or any other page), you'd just use $_SESSION['my_array']
> where you need. 

I would suggest, unsetting the array in the next_page (or whatever) after
don't need it anymore:

> Another option would be to send the request as a post, and
> serialize the array into a hidden variable in your form; that way you
> have to worry (as much) about size constraints.  (a post request is also
> limited in size, but it's so large that you probably would never approach
> the limit.)
> /nick

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to