Skip to main content

Session

A session

Properties

key

Session.key: TKey

The key

keyInfo

Session.keyInfo: DataStoreKeyInfo

data

Session.data: TData

The data

isReleased

Session.isReleased: boolean

Whether or not the session has been released.

isReleasing

Session.isReleasing: boolean

Whether or not the session is currently being released.

store

Session.store: Store

The store

released

Signal
Session.released: Signal<boolean>

Fired whenever the session is released.

The first parameter is a boolean which is true if the data saved, and false if the data could not be saved, this could be because the session was stolen by a different server.

session.released:Connect(function(didSave)
	print(`Session released! didSave: {didSave}`)
end)

Functions

new

Session.new(
storeStore<TKey,TData>,
keyTKey,
dataTData,
) → Session<TKey,TData>

Creates a session with the given key and data

note

You're probably looking for Store:load

update

Session:update() → Promise<()>

Updates the session, saving all data and updating the Session.data and Session.keyInfo properties.

This will also release the session if a different server is requesting a release.

This will also stop the autosave in the current autosave cycle.

release

Session:release() → Promise<()>

Releases this session.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a session with the given `key` and `data`\n\n:::note\nYou're probably looking for [Store:load]\n:::",
            "params": [
                {
                    "name": "store",
                    "desc": "",
                    "lua_type": "Store<TKey, TData>"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "TKey"
                },
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "TData"
                },
                {
                    "name": "keyInfo",
                    "desc": "",
                    "lua_type": "DataStoreKeyInfo"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Session<TKey, TData>\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 104,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "update",
            "desc": "Updates the session, saving all data and updating the\n[Session.data] and [Session.keyInfo] properties.\n\nThis will also release the session if a different server is\nrequesting a release.\n\nThis will also stop the autosave in the current autosave cycle.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 133,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "release",
            "desc": "Releases this session.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 212,
                "path": "lib/Session.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "key",
            "desc": "The key",
            "lua_type": "TKey",
            "source": {
                "line": 19,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "keyInfo",
            "desc": "The [DataStoreKeyInfo]",
            "lua_type": "DataStoreKeyInfo",
            "source": {
                "line": 25,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "data",
            "desc": "The data",
            "lua_type": "TData",
            "source": {
                "line": 31,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "isReleased",
            "desc": "Whether or not the session has been released.",
            "lua_type": "boolean",
            "source": {
                "line": 37,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "isReleasing",
            "desc": "Whether or not the session is currently being released.",
            "lua_type": "boolean",
            "source": {
                "line": 43,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "store",
            "desc": "The store",
            "lua_type": "Store",
            "source": {
                "line": 49,
                "path": "lib/Session.luau"
            }
        },
        {
            "name": "released",
            "desc": "Fired whenever the session is released.\n\nThe first parameter is a boolean which is `true` if the data saved, and\n`false` if the data could not be saved, this could be because the session was\nstolen by a different server.\n\n```lua\nsession.released:Connect(function(didSave)\n\tprint(`Session released! didSave: {didSave}`)\nend)\n```",
            "lua_type": "Signal<boolean>",
            "tags": [
                "Signal"
            ],
            "source": {
                "line": 66,
                "path": "lib/Session.luau"
            }
        }
    ],
    "types": [],
    "name": "Session",
    "desc": "A session",
    "source": {
        "line": 11,
        "path": "lib/Session.luau"
    }
}