开发者

What is a Coldfusion Session?

I've used Coldfusion sessions for quite a while, so I know how they are used, but now I need to know how they work, so that I can plan for scaling my website.

Is a Coldfusion user 'session' simply a quick method to setup 2 cookies (CFTOKEN and CFID) and an associated server side me开发者_如何学运维mory structure? (the SESSION scope) Does it do anything else? I'm trying to identify the overhead associated with user sessions versus other methods such as cookies.


Your understanding of them is basically correct. Although they are not bound to the cookies. The cookies are a recording of a token. That token can get passed in the url string if cookies are not enabled in the browser.

There are 2 main advantages I see of saving things in session instead of cookies:

  1. You control the session scope. People can't edit the data in the session scope without you providing them an interface. Cookies can be modified by the client.
  2. Complex data like structures, arrays, objects, network sessions (FTP, exchange) can be stored there.

Their memory overhead is "low" but that's a relative term. Use the ColdFusion Admin Server Monitor to drill into how much memory your sessions are actually using.


First of all, Session is scope: secure and efficient way to keep current user attributes like permissions or preferences. Not sure what do you mean under "other methods", but I doubt that you'll be able to keep complex data structures (query,object,array) in cookies.

Second, application server provides you with really handy event handlers specially for sessions: onSessionStart() and onSessionEnd().

Third, sessions can be pretty easily shared and clustered: between CF applications or between CF and J2EE.


Sessions are per-user memory space assigned within a particular application space within the jvm memory. The two cookies are pointers to (the token of) that memory space. Yes, there are overhead of using session (RAM, swap space, etc), but unless you're shoving mass amount of data inside the session scope, it shouldn't be that bad.


One aspect of sessions not mentioned is that they have a lifetime: by default 20 minutes (of inactivity). This lifetime can be set by application, but can never be more than the limit set in ColdFusion Administrator.

If memory usage is a concern the time limit could be reduced, although there's still much that depends on the Java garbage collection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜