> For the complete documentation index, see [llms.txt](https://muradkarakas.gitbook.io/sodium_documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://muradkarakas.gitbook.io/sodium_documentation/language-reference/built-in-triggers/page.access-trigger.md).

# "page.access" trigger

#### Description

`page.access` trigger function is optional. if it is needed, must be in [Code Behind File](/sodium_documentation/language-reference/program-structure/code-behind-file.md).

Whenever a [Form File](/sodium_documentation/language-reference/program-structure/form-file.md) is requested, `page.access` function is called before procession file request.\
&#x20;If the function does **not exist**, this means that requested file is public and all requests are granted.\
&#x20;If `page.access` trigger function **exists** and;

* returns `true`, end users have been granted to access the page.
* returns `false`, the request has been refused.

**Since it runs before page processing starts, `page.access` trigger function has the following restrictions:**

* HTML elements defined in [Form File](/sodium_documentation/language-reference/program-structure/form-file.md) (like data/control blocks, data lists) are not available/accessible in the trigger function code.
* Functions defined in [Code Behind File](/sodium_documentation/language-reference/program-structure/code-behind-file.md) are not available/accessible also.

**What can be done in `page.access` trigger function:**

* For authentication: Executing SQL statement in order to get user credentials from database tables.
* For authorization: Executing SQL statement in order to get user privileges.
* Logging: Executing SQL statement in order to insert/update log tables.
* Setting/getting session variables.
* Reading/writing files on disk.

**Be careful:** Usage of the `page.access` trigger function in "log on pages" must not block to accessing that page. In other words, the trigger function for log on page must always return true if exists. Otherwise nobody authenticate themselves to the application.

**Declaration**

```
bool page.access();
```

#### **Example**

```
bool page.access() {
    return :Session.authenticated;
}
```

#### **See also**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://muradkarakas.gitbook.io/sodium_documentation/language-reference/built-in-triggers/page.access-trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
