location

Stops execution of the current page and redirects to the given URL.

location(url [, addtoken] [, statuscode]) → returns void

Argument Reference

url string
Required

URL of web page to open.

addtoken boolean
Default: true

clientManagement must be enabled (see cfapplication).

statuscode numeric
Default: 302

The HTTP status code
Values:
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307

Compatibility

ColdFusion:

Version 9+ Implemented as both a function and an alias to the cflocation tag in script, so named parameters can be used prior to CF2018+. CF11+ addtoken default value is false when Secure Profile is enabled

Examples
Sample code invoking the location function

Relocates to a different page if user is not logged in.

if (!structKeyExists(session, "userID") {
	location("login.cfm");
}

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub