docs
Loading...
Searching...
No Matches
CAPI_Session.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5
6///
7/// @file CAPI_Session.h
8///
9/// Storage for a browsing session (cookies, local storage, etc.).
10///
11/// `#include <Ultralight/CAPI/CAPI_Session.h>`
12///
13/// This class stores data for a unique browsing session (cookies, local storage, application cache,
14/// indexed db. etc.). You can create multiple sessions to isolate data between different browsing
15/// contexts.
16///
17/// ## Default Session
18///
19/// The library has a default session named "default" that is used if no session is specified when
20/// when creating a View.
21///
22/// ## Session Lifetime
23///
24/// Sessions can be either temporary (in-memory only) or persistent (backed to disk).
25///
26#ifndef ULTRALIGHT_CAPI_SESSION_H
27#define ULTRALIGHT_CAPI_SESSION_H
28
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/******************************************************************************
36 * Session
37 *****************************************************************************/
38
39///
40/// Create a Session to store local data in (such as cookies, local storage, application cache,
41/// indexed db, etc).
42///
43/// @param renderer The active renderer instance.
44///
45/// @param is_persistent Whether or not to store the session on disk. Persistent sessions are
46/// stored in a subfolder of the config's cache path with this session's
47/// name.
48///
49/// @param name A unique name for this session.
50///
51/// @return Returns a new ULSession instance. You must call ulDestroySession() when finished.
52///
53/// @note The library doesn't check that names are unique: two persistent sessions with the
54/// same name share one folder.
55///
56ULExport ULSession ulCreateSession(ULRenderer renderer, bool is_persistent, ULString name);
57
58///
59/// Destroy a Session previously created with ulCreateSession().
60///
61/// @param session The session instance to destroy (can be NULL).
62///
63/// @warning Do not destroy the default session returned by ulDefaultSession().
64///
66
67///
68/// Get the default session (persistent session named "default").
69///
70/// @note This session is owned by the Renderer, you shouldn't destroy it.
71///
73
74///
75/// Whether or not is persistent (backed to disk).
76///
78
79///
80/// Unique name identifying the session (used for unique disk path).
81///
82/// @note Do not destroy the returned string, it is owned by the Session. This value is reset
83/// with every call-- if you want to retain it you should copy it via ulCreateStringFromCopy().
84///
86
87///
88/// Unique numeric Id for the session.
89///
90ULExport unsigned long long ulSessionGetId(ULSession session);
91
92///
93/// The disk path to write to (used by persistent sessions only).
94///
95/// @note Do not destroy the returned string, it is owned by the Session. This value is reset
96/// with every call-- if you want to retain it you should copy it via ulCreateStringFromCopy().
97///
99
100#ifdef __cplusplus
101} // extern "C"
102#endif
103
104#endif // ULTRALIGHT_CAPI_SESSION_H
bool ulSessionIsPersistent(ULSession session)
Whether or not is persistent (backed to disk).
unsigned long long ulSessionGetId(ULSession session)
Unique numeric Id for the session.
void ulDestroySession(ULSession session)
Destroy a Session previously created with ulCreateSession().
ULSession ulDefaultSession(ULRenderer renderer)
Get the default session (persistent session named "default").
ULString ulSessionGetDiskPath(ULSession session)
The disk path to write to (used by persistent sessions only).
ULSession ulCreateSession(ULRenderer renderer, bool is_persistent, ULString name)
Create a Session to store local data in (such as cookies, local storage, application cache,...
ULString ulSessionGetName(ULSession session)
Unique name identifying the session (used for unique disk path).
Various defines and utility functions for the C API.
struct C_String * ULString
Opaque handle to a String object.
Definition CAPI_Defines.h:96
struct C_Session * ULSession
Opaque handle to a Session object.
Definition CAPI_Defines.h:81
#define ULExport
Definition CAPI_Defines.h:42
struct C_Renderer * ULRenderer
Opaque handle to a Renderer object.
Definition CAPI_Defines.h:78