ktor-server-core / io.ktor.sessions / SessionTrackerById

SessionTrackerById

class SessionTrackerById<S : Any> : SessionTracker<S>

SessionTracker that transfers a Session Id generated by a sessionIdProvider in HTTP Headers/Cookies. It uses a storage and a serializer to store/load serialized/deserialized session content of a specific type.

Constructors

<init>

SessionTrackerById(type: KClass<S>, serializer: SessionSerializer<S>, storage: SessionStorage, sessionIdProvider: () -> String)

SessionTracker that transfers a Session Id generated by a sessionIdProvider in HTTP Headers/Cookies. It uses a storage and a serializer to store/load serialized/deserialized session content of a specific type.

Properties

serializer

val serializer: SessionSerializer<S>

session serializer

sessionIdProvider

val sessionIdProvider: () -> String

is a function that generates session IDs

storage

val storage: SessionStorage

session storage to store session

type

val type: KClass<S>

is a session instance type

Functions

clear

suspend fun clear(call: ApplicationCall): Unit

Clear session information

load

suspend fun load(call: ApplicationCall, transport: String?): S?

Load session value from transport string for the specified call

store

suspend fun store(call: ApplicationCall, value: S): String

Store session value and return respective transport string for the specified call.

toString

fun toString(): String

validate

fun validate(value: S): Unit

Validate session information