Skip to content

Set-PodeCookie

SYNOPSIS

Sets a cookie on the Response.

SYNTAX

Duration (Default)

Set-PodeCookie -Name <String> [-Value <String>] [-Secret <String>] [-Duration <Int32>] [-HttpOnly] [-Discard]
 [-Secure] [<CommonParameters>]

ExpiryDate

Set-PodeCookie -Name <String> [-Value <String>] [-Secret <String>] [-ExpiryDate <DateTime>] [-HttpOnly]
 [-Discard] [-Secure] [<CommonParameters>]

DESCRIPTION

Sets a cookie on the Response using the "Set-Cookie" header. You can also set cookies to expire, or being signed.

EXAMPLES

EXAMPLE 1

Set-PodeCookie -Name 'Views' -Value 2

EXAMPLE 2

Set-PodeCookie -Name 'Views' -Value 2 -Secret 'hunter2'

EXAMPLE 3

Set-PodeCookie -Name 'Views' -Value 2 -Duration 3600

PARAMETERS

-Discard

Inform browsers to remove the cookie.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Duration

The duration, in seconds, before the cookie is expired.

Type: Int32
Parameter Sets: Duration
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-ExpiryDate

An explicit expiry date for the cookie.

Type: DateTime
Parameter Sets: ExpiryDate
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HttpOnly

Only allow the cookie to be used in browsers.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Name

The name of the cookie.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Secret

If supplied, the secret with which to sign the cookie.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Secure

Only allow the cookie on secure (HTTPS) connections.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Value

The value of the cookie.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Collections.Hashtable

NOTES

Back to top