Jeremy Brodie wrote:
[...]
>
> For a sturcture containing user information a persistant cookie requires
> a connection with local file system and then CF needs to parse out the
> information contained in the structure. Every time you call the cookie,
> you need to run through the same series of steps. Using session

When browsing a web site, I'm sure modern browsers cache cookies for
whatever site you're viewing so the hard drive is accessed as few times
as possible.

> variables, that information is in server RAM or in a nearby database
> --much closer to the center of action.
>
> What do you think would be faster-  reading a file remotely or reading
> server RAM (or nearby database)?

When reading a cookie, you aren't reading a file remotely or even off
the server's filesystem. With every request, any cookies are sent back
to the web server where they came from. It's like a cgi variable (in
fact, browse your cgi debugging info and you'll see cookies there).
Cookie variables can be called from CF just as quickly as any variable.

However, if you're saving variables in a "nearby database", this WILL be
slower, as CF has to run across the network to get it, or run through
its own filesystem to pull it out of a 3rd party connection (jdbc, odbc,
access files, sql servers, none as fast as a cookie variable on the page).

Now as for the whole which is faster, It's hard to say. Cookies require
additional bandwidth, which slows down the perception of a page, and
they are limited to a handful of data per site. However, once they get
to the site, the actual CFM page processing is quick, but Jeremy was
right about needing more code to validate their values, and you have
potential security risks. Session vars have different security risks,
though at a higher level. For a server to access a session, it has to
search through its memory structures to find the right session, then the
right variable you're using.

So which is faster? I don't really think it matters. But which is
better? It depends on the job.

-nathan strutz
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to