jrCore_window_location()

Applies to: Jamroom 7.0+ Last verified: 2026-10-24
  • What it does

    jrCore_window_location(url) sends the browser to a URL, like window.location = url. It also sets a short-lived CSRF cookie naming that URL. The view at the URL can then check that the request came from your own site, and not from a link on another site (cross-site request forgery).

    <a onclick="jrCore_window_location('{$jamroom_url}/{$murl}/delete/id={$item._item_id}')">Delete</a>
  • Checking it in the view

    At the top of a view that changes something, such as a delete, call:

    jrCore_validate_location_url();
  • If the cookie is missing or names another URL, the request is refused. So a link to a protected view must use jrCore_window_location(), not a plain href. Otherwise the view refuses it.

    If the URL has a # fragment and the browser is already on that page, the page is reloaded.

Tags