< Back

Enable-PodeSessionMiddleware

Sat Jan 18, 2020 7:15 pm

NAME Enable-PodeSessionMiddleware



SYNOPSIS

Enables Middleware for creating, retrieving and using Sessions within Pode.





SYNTAX

Enable-PodeSessionMiddleware [-Secret] <String> [[-Name] <String>] [[-Duration] <Int32>] [[-Generator]

<ScriptBlock>] [[-Storage] <PSObject>] [-Extend] [-HttpOnly] [-Secure] [<CommonParameters>]





DESCRIPTION

Enables Middleware for creating, retrieving and using Sessions within Pode. With support for defining Session

duration, and custom Storage.





PARAMETERS

-Secret <String>

A secret to use when signing Session cookies.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

The name of the cookie Sessions use.



Required? false

Position? 2

Default value pode.sid

Accept pipeline input? false

Accept wildcard characters? false



-Duration <Int32>

The duration a Session cookie should last for, before being expired.



Required? false

Position? 3

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Generator <ScriptBlock>

A custom ScriptBlock to generate a random unique SessionId. The value returned must be a String.



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Storage <PSObject>

A custom PSObject that defines methods for Delete, Get, and Set. This allow you to store Sessions in custom

Storage such as Redis.



Required? false

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Extend [<SwitchParameter>]

If supplied, the Session's cookie will have its duration extended on each successful Request.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-HttpOnly [<SwitchParameter>]

If supplied, the Session cookie will only be accessible to browsers.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Secure [<SwitchParameter>]

If supplied, the Session cookie will only be accessible over HTTPS Requests.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Enable-PodeSessionMiddleware -Secret 'schwifty' -Duration 120













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Enable-PodeSessionMiddleware -Secret 'schwifty' -Duration 120 -Extend -Generator { return

[System.IO.Path]::GetRandomFileName() }















RELATED LINKS