web.session
web.session
Function
Read and save the current request Session object.
Syntax
web.session
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Object | Returns the Session object of the current request. |
Object structure
| Field | Type | Description |
|---|---|---|
| Any Session key name | Any | The value saved in the current Session. Supports JSON expressible String, Int, Float, Bool, Array, Object, and Null; when the key does not exist, the read result is Empty. |
Example
web.session.user = 'BT' result = web.session.user // Output: BT print result
Notes
- The bottom layer of Session saves JSON strings in __bt_session_json.
- At the end of the request,
web.sessionwill be serialized into JSON and saved. - Non-JSON basic values such as Fs, functions, and class instances will be written to the Session as strings. It is not recommended to directly save such runtime objects.