# Session methods

## \_\_get( key )

Magic method to get a data key from the session.

* **`key`** The data key to retrieve

**Returns:** The requested value from the session

## \_isset( key ) <a href="#issessiondata" id="issessiondata"></a>

Magic method to check whether a session data key has been set or not.

* **`key`** The data key to check

**Returns:** True if the data key exists in the session, false if not.

## \_\_set( key, value ) <a href="#setsessiondata" id="setsessiondata"></a>

Magic method to store a value with the given key in the session data. It does it both in the hashed list cache and on the database for persistence.

* **`key`** The data key to store
* **`value`** The value to store

**Returns:** Whether the value could be stored or not.

## \_\_unset( key )

Magic method to remove the given key from the session.

* **`key`** The data key to remove


---

# Agent Instructions: 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://cherrycake.tin.cat/version-0.x/reference/core-modules/session/session-methods.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.
