docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C API
2.0.0
Toggle main menu visibility
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
29
#include <
Ultralight/CAPI/CAPI_Defines.h
>
30
31
#ifdef __cplusplus
32
extern
"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
///
56
ULExport
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
///
65
ULExport
void
ulDestroySession
(
ULSession
session);
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
///
72
ULExport
ULSession
ulDefaultSession
(
ULRenderer
renderer);
73
74
///
75
/// Whether or not is persistent (backed to disk).
76
///
77
ULExport
bool
ulSessionIsPersistent
(
ULSession
session);
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
///
85
ULExport
ULString
ulSessionGetName
(
ULSession
session);
86
87
///
88
/// Unique numeric Id for the session.
89
///
90
ULExport
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
///
98
ULExport
ULString
ulSessionGetDiskPath
(
ULSession
session);
99
100
#ifdef __cplusplus
101
}
// extern "C"
102
#endif
103
104
#endif
// ULTRALIGHT_CAPI_SESSION_H
ulSessionIsPersistent
bool ulSessionIsPersistent(ULSession session)
Whether or not is persistent (backed to disk).
ulSessionGetId
unsigned long long ulSessionGetId(ULSession session)
Unique numeric Id for the session.
ulDestroySession
void ulDestroySession(ULSession session)
Destroy a Session previously created with ulCreateSession().
ulDefaultSession
ULSession ulDefaultSession(ULRenderer renderer)
Get the default session (persistent session named "default").
ulSessionGetDiskPath
ULString ulSessionGetDiskPath(ULSession session)
The disk path to write to (used by persistent sessions only).
ulCreateSession
ULSession ulCreateSession(ULRenderer renderer, bool is_persistent, ULString name)
Create a Session to store local data in (such as cookies, local storage, application cache,...
ulSessionGetName
ULString ulSessionGetName(ULSession session)
Unique name identifying the session (used for unique disk path).
CAPI_Defines.h
Various defines and utility functions for the C API.
ULString
struct C_String * ULString
Opaque handle to a String object.
Definition
CAPI_Defines.h:96
ULSession
struct C_Session * ULSession
Opaque handle to a Session object.
Definition
CAPI_Defines.h:81
ULExport
#define ULExport
Definition
CAPI_Defines.h:42
ULRenderer
struct C_Renderer * ULRenderer
Opaque handle to a Renderer object.
Definition
CAPI_Defines.h:78
Ultralight
CAPI
CAPI_Session.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4