Package io.ktor.sessions
Types
class CacheStorage : SessionStorage |
|
class CookieConfiguration Cookie configuration being used to send sessions |
|
class CookieIdSessionBuilder<S : Any> : Cookie session configuration builder |
|
open class CookieSessionBuilder<S : Any> Cookie session configuration builder |
|
interface CurrentSession Represents a container for all session instances |
|
class HeaderIdSessionBuilder<S : Any> : Header session configuration builder |
|
open class HeaderSessionBuilder<S : Any> Header session configuration builder |
|
class SessionProvider<S : Any> Specifies a provider for a session with the specific name and type |
|
interface SessionSerializer<T> Serializes session from and to String |
|
class Default reflection-based session serializer that does it via reflection. Serialized format is textual and optimized for size as it is could be transferred via HTTP headers or cookies |
|
interface SessionStorage Represents a way to write, read and invalidate session bits. |
|
class SessionStorageMemory : SessionStorage SessionStorage that stores session contents into memory. |
|
interface SessionTracker<S : Any> SessionTracker provides ability to track and extract session from the call context. |
|
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. |
|
class SessionTrackerByValue<S : Any> : SessionTracker<S> SessionTracker that stores the contents of the session as part of HTTP Cookies/Headers. It uses a specific serializer to serialize and deserialize objects of type type. |
|
interface SessionTransport SessionTransport receive, send or clear a session from/to an ApplicationCall. |
|
class SessionTransportCookie : SessionTransport SessionTransport that adds a Set-Cookie header and reads Cookie header for the specified cookie name, and a specific cookie configuration after applying/un-applying the specified transforms defined by transformers. |
|
class SessionTransportHeader : SessionTransport SessionTransport that sets or gets the specific header name, applying/un-applying the specified transforms defined by transformers. |
|
interface SessionTransportTransformer Represents a session cookie transformation. Useful for such things like signing and encryption |
|
class Session transformer that appends an algorithm hash of the input. Where the input is either a session contents or a previous transformation. It prepends a salt when computing the hash. |
|
class SessionTransportTransformerEncrypt : Session transformer that encrypts/decrypts the input. |
|
class SessionTransportTransformerMessageAuthentication : Session transformer that appends an algorithm MAC (Message Authentication Code) hash of the input. Where the input is either a session contents or a previous transformation. It uses a specified keySpec when generating the Mac hash. |
|
class Sessions Sessions feature that provides a mechanism to persist information between requests. |
Exceptions
class SessionNotYetConfiguredException : This exception is thrown when a session is asked too early before the Sessions feature had chance to configure it. For example, in a phase before ApplicationCallPipeline.Features or in a feature installed before Sessions into the same phase. |
|
class TooLateSessionSetException : IllegalStateException This exception is thrown when HTTP response has been already sent but an attempt to modify session is made |
Extensions for External Classes
Properties
const val DEFAULT_SESSION_MAX_AGE: Long |
|
var CookieConfiguration. |
|
val ApplicationCall.sessionId: String? Returns a sessionId for for a single session identified by ID. This will not work if there are multiple sessions by ID were registered or the Sessions feature is not installed. If you are using multiple sessions, please use sessionId function instead. |
|
val ApplicationCall.sessions: CurrentSession Get current session or fail if no session feature installed |
Functions
fun <T : Any> Creates the the default SessionSerializer for type T fun <T : Any> Creates the the default SessionSerializer for class type |
|
fun <T> CurrentSession.clear(): Unit Clear session instance with type T |
|
fun <S : Any> Configuration. fun <S : Any> Configuration.cookie( fun <S : Any> Configuration. Configure sessions to get it from cookie using session storage fun <S : Any> Configuration.cookie( Configures a session using a cookie with the specified name using it as a session id. The actual content of the session is stored at server side using the specified storage. The cookie configuration can be set inside block using the cookie property exposed by CookieIdSessionBuilder. fun <S : Any> Configuration.cookie(name: String): Unit Configure sessions to serialize to/from HTTP cookie fun <S : Any> Configuration.cookie( Configures a session using a cookie with the specified name using it as for the actual session content optionally transformed by specified transforms in block. The cookie configuration can be set inside block using the cookie property exposed by CookieIdSessionBuilder. fun <S : Any> Configuration. Configure sessions to serialize to/from HTTP cookie configuring it by block |
|
fun <T : Any> defaultSessionSerializer(): SessionSerializer<T> Creates the default SessionSerializer for type T fun <T : Any> defaultSessionSerializer( Creates the default SessionSerializer by typeInfo |
|
fun directorySessionStorage( Creates a session storage that serializes them into regular files under the specified rootDir |
|
fun generateSessionId(): String Generates a secure random session ID |
|
fun <T> CurrentSession.get(): T? Get session instance with type T |
|
fun <T> CurrentSession.getOrSet( Get or generate a new session instance using generator with type T (or name if specified) |
|
fun <S : Any> Configuration. fun <S : Any> Configuration.header( Configure sessions to get it from HTTP header using session storage fun <S : Any> Configuration.header( fun <S : Any> Configuration. Configures a session using a header with the specified name using it as a session id. The actual content of the session is stored at server side using the specified storage. fun <S : Any> Configuration.header(name: String): Unit Configure sessions to serialize to/from HTTP header fun <S : Any> Configuration.header( Configures a session using a header with the specified name using it for the actual session content optionally transformed by specified transforms in block. fun <S : Any> Configuration. Configures a session using a header with the specified name using it for the actual session content and apply block function to configure serializataion and optional transformations |
|
fun <SessionType : Any> ApplicationCall.sessionId(): String? Returns the corresponding session ID for the type SessionType or |
|
fun <T> CurrentSession.set(value: T?): Unit Set session instance with type T |