View Single Post

  #2 (permalink)  
Old 05-07-2008
Robert Cummings
 
Posts: n/a
Default Re: [PHP] $_SESSION v. Cookies


On Wed, 2008-05-07 at 12:27 -0400, Scott Campbell wrote:
> Dear PHP List,
>
> PHP 5, Apache2, MySQL 5, running on Ubuntu, viewing & deving with
> FireFox and Konqueror (Linux).
>
> I am building a site with multiple tools and want to pass variables
> throughout them all. Before, I was passing variables using <hidden> HTML
> Form tags, but the site has grown too large for this tactic, so I went to
> using $_SESSION. However, when I started using $_SESSION, my site loads 3-5
> times slower then before. A page that queried MySQL and built itself in 3-5
> seconds was now taking 15-20. While more has changed then just $_SESSION,
> it is really the only significant difference.
>
> Is $_SESSION slowing down my site? Is there a faster alternative to
> global variables then using $_SESSION? Are using regular cookies faster?
>
> Any help is appreciated.


How are your sessions implemented? Are you using the stock PHP session
functionality or did you cook your own solution? I can't see the stock
PHP solution adding anything more than a split second to your page time.
The exception being when it performs cleanup. Cleanup should be
relegated to a cron job. Have you added anything new to the database?
new query perhaps on a large table that doesn't make use of indexes?
Small changes can have a bigger impact than large changes depending on
what exactly changed.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

Reply With Quote