Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FormsAuthentication.FormsCookiePath Property

Returns the configured cookie path used for the current application.

[Visual Basic]
Public Shared ReadOnly Property FormsCookiePath As String
[C#]
public static string FormsCookiePath {get;}
[C++]
public: __property static String* get_FormsCookiePath();
[JScript]
public static function get FormsCookiePath() : String;

Property Value

A string containing the configured cookie path used for the current application.

Example

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="true"%>
<script runat="server">

    Sub Page_Load(sender as Object, e as EventArgs)
        If Not IsPostBack Then 
            CookieName.Text = FormsAuthentication.FormsCookieName
            CookiePath.Text = FormsAuthentication.FormsCookiePath
            CookieSSL.Text  = FormsAuthentication.RequireSSL.ToString()
            CookieExpiration.Text = FormsAuthentication.SlidingExpiration.ToString()
        End If
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
    <h2>Current FormsAuthentication Property Settings</h2>
        <table width="90%" align="center" cellpadding="3" border="1">
        <tr><th>Property</th><th>Current Value</th><th>Default Web.config Setting</th></tr>
        <tr>
        <td>FormsCookieName</td>
        <td><asp:Label id="CookieName" runat="server" />
        </td>
        <td rowspan="4">
            &lt;forms
            <br>&nbsp;&nbsp; name=".ASPXAUTH" 
            <br>&nbsp;&nbsp; path="/" 
            <br>&nbsp;&nbsp; requireSSL="true"
            <br>&nbsp;&nbsp; slidingExpiration="true"
            &gt;
            <br>&lt;/forms&gt;
        </td>
        </tr>
        <tr>
        <td>FormsCookiePath</td>
        <td><asp:Label id="CookiePath" runat="server" />
        </td>
        </tr>
        <tr>
        <td>RequireSSL</td>
        <td><asp:Label id="CookieSSL" runat="server" />
        </td>
        </tr>
        <tr>
        <td>SlidingExpiration</td>
        <td><asp:Label id="CookieExpiration" runat="server" />
        </td>
        </tr>
        </table>
    </form>
</body>
</html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="true"%>
<script runat="server">

    private void Page_Load(object Sender, EventArgs e) 
    {
        if (!IsPostBack) 
        {
            CookieName.Text = FormsAuthentication.FormsCookieName;
            CookiePath.Text = FormsAuthentication.FormsCookiePath;
            CookieSSL.Text  = FormsAuthentication.RequireSSL.ToString();
            CookieExpiration.Text = FormsAuthentication.SlidingExpiration.ToString();
        }
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <table width="90%" align="center" cellpadding="3" border="1">
        <tr><th>Property</th><th>Current Value</th><th>Configuration Setting</th></tr>
        <tr>
        <td>FormsCookieName</td>
        <td><asp:Label id="CookieName" runat="server" />
        </td>
        <td rowspan="4">
            &lt;forms
            <br>&nbsp;&nbsp; name=".ASPXAUTH" 
            <br>&nbsp;&nbsp; path="/" 
            <br>&nbsp;&nbsp; requireSSL="true"
            <br>&nbsp;&nbsp; slidingExpiration="true"
            <br>&gt;<br>&lt;/forms&gt;
        </td>
        </tr>
        <tr>
        <td>FormsCookiePath</td>
        <td><asp:Label id="CookiePath" runat="server" />
        </td>
        </tr>
        <tr>
        <td>RequireSSL</td>
        <td><asp:Label id="CookieSSL" runat="server" />
        </td>
        </tr>
        <tr>
        <td>SlidingExpiration</td>
        <td><asp:Label id="CookieExpiration" runat="server" />
        </td>
        </tr>
        </table>
    </form>
</body>
</html>

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

FormsAuthentication Class | FormsAuthentication Members | System.Web.Security Namespace

Show:
© 2015 Microsoft