/
HttpCookie.xml
592 lines (538 loc) · 36.6 KB
/
HttpCookie.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
<Type Name="HttpCookie" FullName="System.Web.HttpCookie">
<TypeSignature Language="C#" Value="public sealed class HttpCookie" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit HttpCookie extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Web.HttpCookie" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class HttpCookie" />
<TypeSignature Language="F#" Value="type HttpCookie = class" />
<TypeSignature Language="C++ CLI" Value="public ref class HttpCookie sealed" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides a type-safe way to create and manipulate individual HTTP cookies.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpCookie> class gets and sets properties of individual cookies. The <xref:System.Web.HttpCookieCollection> class provides methods to store, retrieve, and manage multiple cookies.
ASP.NET includes two intrinsic cookie collections. The collection accessed through the <xref:System.Web.HttpRequest.Cookies%2A> collection of the <xref:System.Web.HttpRequest> object contains cookies transmitted by the client to the server in the `Cookie` header. The collection accessed through the <xref:System.Web.HttpResponse.Cookies%2A> collection of the <xref:System.Web.HttpResponse> object contains new cookies created on the server and transmitted to the client in the `Set-Cookie` HTTP response header.
## Examples
The following code example demonstrates how to check for a cookie named `DateCookieExample` in the <xref:System.Web.HttpRequest> object. If the cookie is not found, it is created and added to the <xref:System.Web.HttpResponse> object. The cookie is set to expire in 10 minutes.
[!code-aspx-csharp[System.Web.HttpCookie#1](~/snippets/csharp/VS_Snippets_WebNet/System.Web.HttpCookie/cs/HttpCookie.cs.aspx#1)]
[!code-aspx-vb[System.Web.HttpCookie#1](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.HttpCookie/vb/HttpCookie.vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.HttpResponse" />
<altmember cref="T:System.Web.HttpRequest" />
<altmember cref="T:System.Web.HttpCookieCollection" />
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.HttpCookie" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpCookie (string name);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpCookie.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String)" />
<MemberSignature Language="F#" Value="new System.Web.HttpCookie : string -> System.Web.HttpCookie" Usage="new System.Web.HttpCookie name" />
<MemberSignature Language="C++ CLI" Value="public:
 HttpCookie(System::String ^ name);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the new cookie.</param>
<summary>Creates and names a new cookie.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example creates and names a new cookie.
[!code-csharp[Classic HttpCookie.HttpCookie Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.HttpCookie Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.HttpCookie Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.HttpCookie Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public HttpCookie (string name, string value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name, string value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpCookie.#ctor(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String, value As String)" />
<MemberSignature Language="F#" Value="new System.Web.HttpCookie : string * string -> System.Web.HttpCookie" Usage="new System.Web.HttpCookie (name, value)" />
<MemberSignature Language="C++ CLI" Value="public:
 HttpCookie(System::String ^ name, System::String ^ value);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="value" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the new cookie.</param>
<param name="value">The value of the new cookie.</param>
<summary>Creates, names, and assigns a value to a new cookie.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example creates, names, and sets the value of a new cookie.
[!code-csharp[Classic HttpCookie.HttpCookie1 Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.HttpCookie1 Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.HttpCookie1 Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.HttpCookie1 Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Domain">
<MemberSignature Language="C#" Value="public string Domain { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Domain" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Domain" />
<MemberSignature Language="VB.NET" Value="Public Property Domain As String" />
<MemberSignature Language="F#" Value="member this.Domain : string with get, set" Usage="System.Web.HttpCookie.Domain" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Domain { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the domain to associate the cookie with.</summary>
<value>The name of the domain to associate the cookie with. The default value is the current domain.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Setting the `Domain` attribute limits transmission of the cookie to clients requesting a resource from that domain.
## Examples
The following code example sets the cookie's domain.
[!code-csharp[Classic HttpCookie.Domain Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Domain Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Domain Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Domain Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Expires">
<MemberSignature Language="C#" Value="public DateTime Expires { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.DateTime Expires" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Expires" />
<MemberSignature Language="VB.NET" Value="Public Property Expires As DateTime" />
<MemberSignature Language="F#" Value="member this.Expires : DateTime with get, set" Usage="System.Web.HttpCookie.Expires" />
<MemberSignature Language="C++ CLI" Value="public:
 property DateTime Expires { DateTime get(); void set(DateTime value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.DateTime</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the expiration date and time for the cookie.</summary>
<value>The time of day (on the client) at which the cookie expires.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example sets the expiration time of the cookie to 10 minutes from the current time.
[!code-csharp[Classic HttpCookie.Expires Example#2](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Expires Example/CS/default.aspx#2)]
[!code-vb[Classic HttpCookie.Expires Example#2](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Expires Example/VB/default.aspx#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="HasKeys">
<MemberSignature Language="C#" Value="public bool HasKeys { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool HasKeys" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.HasKeys" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property HasKeys As Boolean" />
<MemberSignature Language="F#" Value="member this.HasKeys : bool" Usage="System.Web.HttpCookie.HasKeys" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool HasKeys { bool get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether a cookie has subkeys.</summary>
<value>
<see langword="true" /> if the cookie has subkeys, otherwise, <see langword="false" />. The default value is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example examines each member of a cookie collection for multiple values. If a cookie's <xref:System.Web.HttpCookie.HasKeys%2A> property is `true`, indicating that multiple values are present, this example copies the value names into one string array and the corresponding values into another string array. For an example of how to create multiple values for a cookie, see <xref:System.Web.HttpCookie.Values%2A>.
[!code-csharp[Classic HttpCookie.HasKeys Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.HasKeys Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.HasKeys Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.HasKeys Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Collections.Specialized.NameValueCollection" />
<altmember cref="P:System.Web.HttpCookie.Value" />
</Docs>
</Member>
<Member MemberName="HttpOnly">
<MemberSignature Language="C#" Value="public bool HttpOnly { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool HttpOnly" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.HttpOnly" />
<MemberSignature Language="VB.NET" Value="Public Property HttpOnly As Boolean" />
<MemberSignature Language="F#" Value="member this.HttpOnly : bool with get, set" Usage="System.Web.HttpCookie.HttpOnly" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool HttpOnly { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that specifies whether a cookie is accessible by client-side script.</summary>
<value>
<see langword="true" /> if the cookie has the <see langword="HttpOnly" /> attribute and cannot be accessed through a client-side script; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Microsoft Internet Explorer version 6 Service Pack 1 and later supports a cookie property, <xref:System.Web.HttpCookie.HttpOnly%2A>, that can help mitigate cross-site scripting threats that result in stolen cookies. Stolen cookies can contain sensitive information identifying the user to the site, such as the ASP.NET session ID or forms authentication ticket, and can be replayed by the attacker in order to masquerade as the user or obtain sensitive information. When an `HttpOnly` cookie is received by a compliant browser, it is inaccessible to client-side script.
> [!CAUTION]
> Setting the <xref:System.Web.HttpCookie.HttpOnly%2A> property to `true` does not prevent an attacker with access to the network channel from accessing the cookie directly. Consider using Secure Sockets Layer (SSL) to help protect against this. Workstation security is also important, as a malicious user could use an open browser window or a computer containing persistent cookies to obtain access to a Web site with a legitimate user's identity.
## Examples
The following code example demonstrates how to write an `HttpOnly` cookie and shows how it is not accessible by the client through ECMAScript.
[!code-aspx-csharp[HttpOnlyCookie#1](~/snippets/csharp/VS_Snippets_WebNet/HttpOnlyCookie/CS/httponlycookiecs.aspx#1)]
[!code-aspx-vb[HttpOnlyCookie#1](~/snippets/visualbasic/VS_Snippets_WebNet/HttpOnlyCookie/vb/httponlycookievb.aspx#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public string this[string key] { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Item(string)" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Item(System.String)" />
<MemberSignature Language="VB.NET" Value="Default Public Property Item(key As String) As String" />
<MemberSignature Language="F#" Value="member this.Item(string) : string with get, set" Usage="System.Web.HttpCookie.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ key); void set(System::String ^ key, System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
</Parameters>
<Docs>
<param name="key">The key (index) of the cookie value.</param>
<summary>Gets a shortcut to the <see cref="P:System.Web.HttpCookie.Values" /> property. This property is provided for compatibility with previous versions of Active Server Pages (ASP).</summary>
<value>The cookie value.</value>
<remarks>To be added.</remarks>
<altmember cref="P:System.Web.HttpCookie.Value" />
</Docs>
</Member>
<Member MemberName="Name">
<MemberSignature Language="C#" Value="public string Name { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Name" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Name" />
<MemberSignature Language="VB.NET" Value="Public Property Name As String" />
<MemberSignature Language="F#" Value="member this.Name : string with get, set" Usage="System.Web.HttpCookie.Name" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name of a cookie.</summary>
<value>The default value is a null reference (<see langword="Nothing" /> in Visual Basic) unless the constructor specifies otherwise.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example receives a cookie collection from the client in the `Cookie` header and loops through the collection looking for a cookie with the specific name.
[!code-csharp[Classic HttpCookie.Name Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Name Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Name Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Name Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.HttpCookie.Value" />
</Docs>
</Member>
<Member MemberName="Path">
<MemberSignature Language="C#" Value="public string Path { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Path" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Path" />
<MemberSignature Language="VB.NET" Value="Public Property Path As String" />
<MemberSignature Language="F#" Value="member this.Path : string with get, set" Usage="System.Web.HttpCookie.Path" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Path { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the virtual path to transmit with the current cookie.</summary>
<value>The virtual path to transmit with the cookie. The default is <see langword="/" />, which is the server root.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.HttpCookie.Path%2A> property extends the <xref:System.Web.HttpCookie.Domain%2A> property to completely describe the specific URL to which the cookie applies. For example, in the URL `http:/www.microsoft.com/asp`, the domain is `www.microsoft.com` and the path is /asp.
## Examples
The following code example sets the <xref:System.Web.HttpCookie.Path%2A> property of a new cookie.
[!code-csharp[Classic HttpCookie.Path Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Path Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Path Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Path Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.HttpCookie.Domain" />
</Docs>
</Member>
<Member MemberName="SameSite">
<MemberSignature Language="C#" Value="public System.Web.SameSiteMode SameSite { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.SameSiteMode SameSite" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.SameSite" />
<MemberSignature Language="VB.NET" Value="Public Property SameSite As SameSiteMode" />
<MemberSignature Language="F#" Value="member this.SameSite : System.Web.SameSiteMode with get, set" Usage="System.Web.HttpCookie.SameSite" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::SameSiteMode SameSite { System::Web::SameSiteMode get(); void set(System::Web::SameSiteMode value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SameSiteMode</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the value for the SameSite attribute of the cookie.</summary>
<value>One of the enumeration values that represents the enforcement mode of the cookie or `(SameSiteMode)(-1)` (represented by the string `Unspecified` in config files). The default value depends on updates. For more information on defaults and recent updates, see Remarks.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The default value of this property was modifed by updates described in [KB article 4531182](https://support.microsoft.com/help/4531182/kb4531182) and [KB article 4524421](https://support.microsoft.com/help/4524421/kb4524421).
Without these updates, the default value is <xref:System.Web.SameSiteMode.None?displayProperty=nameWithType>, which does not emit the `SameSite` cookie header. This conforms to [https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1](https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1).
After these updates have been applied, the default value is `(SameSiteMode)(-1)`, which corresponds to `Unspecified`. This preserves the earlier behavior. Setting `SameSiteMode.None` causes "SameSite=None" to be emitted. This new behavior conforms to [https://tools.ietf.org/html/draft-west-cookie-incrementalism-00](https://tools.ietf.org/html/draft-west-cookie-incrementalism-00).
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Secure">
<MemberSignature Language="C#" Value="public bool Secure { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool Secure" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Secure" />
<MemberSignature Language="VB.NET" Value="Public Property Secure As Boolean" />
<MemberSignature Language="F#" Value="member this.Secure : bool with get, set" Usage="System.Web.HttpCookie.Secure" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool Secure { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value indicating whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.</summary>
<value>
<see langword="true" /> to transmit the cookie over an SSL connection (HTTPS); otherwise, <see langword="false" />. The default value is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To set the transmission of cookies using SSL for an entire application, enable it in the application's configuration file, Web.config, which resides in the root directory of the application. For more information, see [httpCookies Element (ASP.NET Settings Schema)](/previous-versions/dotnet/netframework-4.0/ms228262(v=vs.100)). Values set programmatically using the <xref:System.Web.HttpCookie.Secure%2A> property override values set in the Web.config file.
When dealing with sensitive information, it is strongly recommended that you use HTTPS protocol with SSL encryption. SSL protects against data being altered (data integrity), protects a user's identity (confidentiality), and assures that data originates from the expected client (authentication). For more information on the benefits of encryption, see [Cryptographic Services](/dotnet/standard/security/cryptographic-services).
## Examples
The following code example takes action if the cookie is set to transmit using SSL.
[!code-csharp[Classic HttpCookie.Secure Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Secure Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Secure Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Secure Example/VB/source.vb#1)]
]]></format>
</remarks>
<related type="Article" href="/dotnet/framework/network-programming/using-secure-sockets-layer">Using Secure Sockets Layer</related>
</Docs>
</Member>
<Member MemberName="Shareable">
<MemberSignature Language="C#" Value="public bool Shareable { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool Shareable" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Shareable" />
<MemberSignature Language="VB.NET" Value="Public Property Shareable As Boolean" />
<MemberSignature Language="F#" Value="member this.Shareable : bool with get, set" Usage="System.Web.HttpCookie.Shareable" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool Shareable { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Determines whether the cookie is allowed to participate in output caching.</summary>
<value>
<see langword="true" /> to specify that output caching will not be suppressed for a give <see cref="T:System.Web.HttpResponse" /> containing one or more outbound cookies; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If a given <xref:System.Web.HttpResponse> contains one or more outbound cookies with <xref:System.Web.HttpCookie.Shareable%2A> is set to `false` (the default value), output caching will be suppressed for the response. This prevents cookies that contain potentially sensitive information from being cached in the response and sent to multiple clients. To allow a response containing cookies to be cached, configure caching normally for the response, such as using the `OutputCache` directive or MVC's [OutputCache] attribute, and set all outbound cookies to have <xref:System.Web.HttpCookie.Shareable%2A> set to `true`.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="TryParse">
<MemberSignature Language="C#" Value="public static bool TryParse (string input, out System.Web.HttpCookie result);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool TryParse(string input, [out] class System.Web.HttpCookie& result) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.HttpCookie.TryParse(System.String,System.Web.HttpCookie@)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function TryParse (input As String, ByRef result As HttpCookie) As Boolean" />
<MemberSignature Language="F#" Value="static member TryParse : string * HttpCookie -> bool" Usage="System.Web.HttpCookie.TryParse (input, result)" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool TryParse(System::String ^ input, [Runtime::InteropServices::Out] System::Web::HttpCookie ^ % result);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="input" Type="System.String" Index="0" FrameworkAlternate="netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<Parameter Name="result" Type="System.Web.HttpCookie" RefType="out" Index="1" FrameworkAlternate="netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
</Parameters>
<Docs>
<param name="input">The string representation of a cookie.</param>
<param name="result">If the conversion succeeded, contains the <see cref="T:System.Web.HttpCookie" /> value equivalent to the cookie contained in <paramref name="input" />. If the conversion failed, <paramref name="result" /> is <see langword="null" />. The conversion fails if the <paramref name="input" /> parameter is <see langword="null" /> or empty or if a cookie name can't be determined from <paramref name="input" />. This parameter's value is overwritten by the method; the parameter is passed by reference and set to null as soon as the method is entered.</param>
<summary>Converts the specified string representation of a cookie into its <see cref="T:System.Web.HttpCookie" /> equivalent and returns a value that indicates whether the conversion succeeded.</summary>
<returns>
<see langword="true" /> if <paramref name="input" /> was converted successfully; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Value">
<MemberSignature Language="C#" Value="public string Value { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Value" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Value" />
<MemberSignature Language="VB.NET" Value="Public Property Value As String" />
<MemberSignature Language="F#" Value="member this.Value : string with get, set" Usage="System.Web.HttpCookie.Value" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Value { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets an individual cookie value.</summary>
<value>The value of the cookie. The default value is a null reference (<see langword="Nothing" /> in Visual Basic).</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example sets the value of an existing cookie to "abc123".
[!code-csharp[Classic HttpCookie.Value Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Value Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Value Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Value Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Values">
<MemberSignature Language="C#" Value="public System.Collections.Specialized.NameValueCollection Values { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Specialized.NameValueCollection Values" />
<MemberSignature Language="DocId" Value="P:System.Web.HttpCookie.Values" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Values As NameValueCollection" />
<MemberSignature Language="F#" Value="member this.Values : System.Collections.Specialized.NameValueCollection" Usage="System.Web.HttpCookie.Values" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Collections::Specialized::NameValueCollection ^ Values { System::Collections::Specialized::NameValueCollection ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.Specialized.NameValueCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a collection of key/value pairs that are contained within a single cookie object.</summary>
<value>A collection of cookie values.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example creates a new cookie and adds several values to it. For an example of how to extract multiple values from one cookie, see <xref:System.Web.HttpCookie.HasKeys%2A>.
[!code-csharp[Classic HttpCookie.Values Example#1](~/snippets/csharp/VS_Snippets_WebNet/Classic HttpCookie.Values Example/CS/source.cs#1)]
[!code-vb[Classic HttpCookie.Values Example#1](~/snippets/visualbasic/VS_Snippets_WebNet/Classic HttpCookie.Values Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.HttpCookie.Value" />
</Docs>
</Member>
</Members>
</Type>