The redirect component

Redirects the user to another page. This component is useful for implementing redirects after a form submission, or to redirect users to a login page if they are not logged in.

    Contrary to the http_header component, this component completely stops the execution of the page after it is called,
    so it is suitable to use to hide sensitive information from users that are not logged in, for example.

    Since it uses an HTTP header to redirect the user, it is not possible to use this component after the page has started being sent to the browser.

Introduced in SQLPage v0.7.2.

Top-level parameters

link

REQUIRED. The URL to redirect the user to.

Examples

Redirect a user to the login page if they are not logged in:

SELECT 'redirect' AS component, 'login.sql' AS link
WHERE NOT EXISTS (SELECT 1 FROM login_session WHERE id = sqlpage.cookie('session_id'));

See also: other components