Skip to main content
Inspiring
May 27, 2010
Question

tax rate - store it in a session variable ?

  • May 27, 2010
  • 4 replies
  • 1143 views

Here in the UK, the tax rate is currently at 17.5% and could, in theory, be subject to change at short notice.

It's not worth storing this in an application variable as an application can last for days

It's not worth storing it in a table, as the site only sells to the UK, so it's not as if there's a list of tax rates, depending on country.

Is it better to store it in a session variable ? A session only lasts 45 minutes.

Or is there a better way it can be stored - where any changes to the tax rate variable, are reflected immediately ?

This topic has been closed for replies.

4 replies

Inspiring
May 28, 2010

I would just declare my tax rate in the application.cfc/cfm

Inspiring
May 27, 2010

I disagree with "It's not worth storing it in a table,"

Database records are generally easier to update than source code.

ilssac
Inspiring
May 27, 2010

P.S. A 45 minute session time out is very long for a public internet web application.  It could cause preformance problems if you are not careful.

Remember that is how long the application must be idle before the session times out.  Not how long a user may use the application.  So you are bascially saying you will wait three quarters of an hour to see if the user clicks another link or submits another form to your application before you decide they have left and clear their data.

Very few people stare at a web page that long unless it is some type of long running web application page used on a company intranet for their job!

Inspiring
May 27, 2010

Ah, OK

how long do you recommend for the session to last ? 20 mins ?

ilssac
Inspiring
May 27, 2010

Dax Trajero wrote:

Ah, OK

how long do you recommend for the session to last ? 20 mins ?

The only answer I can suggest is, "As short as possible".  It completely depends on how your users are going to use your application.  But with most public web applications, even 20 minutes is an eternity.  That default value is a comprise made by Adobe nee Macromedia nee Allaire between public web applications and private, company web applications which generally have completely different use patterns.  As well as it was created when the high speed Internet was 56K modems!

But as a starting point, I would not be affraid to go as little as 5 minutes unless you are creating some type of information heavy web application where users will be reading, listening, or watching a lot of information before submitting another request to your site.

Message was edited by: Ian Skinner  Another factor to remember is that the global session timeout you set in the Application.cfc file (or other high level location) can be over written on a individual page with the <cfsetting...> tag.  Allowing you to set a shorter overall timeout for most of your application and only extending it on a few pages where users might spend more time.

ilssac
Inspiring
May 27, 2010

How long the data lasts is not the right way to look at where to store it.

Is the tax rate going to be different from user to user.  If so, session would be appropiate if not, session is not appropiate.

Asuming the tax rate is going to be the same for all users of the application, the application scope would be more appropiate then the session.

It might also be worthy of considering the server scope that would be shared with all the applications running on the same ColdFusion server instance.

As a general rule, you do not want to repeat data when you do not have to.

How long the various scopes lives just informs you about what you may want to do to change the value.