# Posted By

zvasanth on 12/29/07

# Statistics

Viewed 1721 times
Favorited by 0 user(s)

# Related snippets

/ Published in: C#

drunkenprogrammer

Copy this code and paste it in your HTML
2. {
3. ArrayList al = new ArrayList();
6. {
9. }
10. return cc;
11. }
12.
13.
15. {
19. ArrayList al = new ArrayList();
20. int i = 0;
21. int n = strCookTemp.Length;
22. while (i < n)
23. {
24. if (strCookTemp[i].IndexOf("expires=", StringComparison.OrdinalIgnoreCase) > 0)
25. {
26. al.Add(strCookTemp[i] + "," + strCookTemp[i + 1]);
27. i = i + 1;
28. }
29. else
30. {
32. }
33. i = i + 1;
34. }
35. return al;
36. }
37.
38.
40. {
42.
43. int alcount = al.Count;
44. string strEachCook;
45. string[] strEachCookParts;
46. for (int i = 0; i < alcount; i++)
47. {
48. strEachCook = al[i].ToString();
49. strEachCookParts = strEachCook.Split(';');
50. int intEachCookPartsCount = strEachCookParts.Length;
51. string strCNameAndCValue = string.Empty;
52. string strPNameAndPValue = string.Empty;
53. string strDNameAndDValue = string.Empty;
54. string[] NameValuePairTemp;
56.
57. for (int j = 0; j < intEachCookPartsCount; j++)
58. {
59. if (j == 0)
60. {
61. strCNameAndCValue = strEachCookParts[j];
62. if (strCNameAndCValue != string.Empty)
63. {
64. int firstEqual = strCNameAndCValue.IndexOf("=");
65. string firstName = strCNameAndCValue.Substring(0, firstEqual);
66. string allValue = strCNameAndCValue.Substring(firstEqual + 1, strCNameAndCValue.Length - (firstEqual + 1));
67. cookTemp.Name = firstName;
68. cookTemp.Value = allValue;
69. }
70. continue;
71. }
72. if (strEachCookParts[j].IndexOf("path", StringComparison.OrdinalIgnoreCase) >= 0)
73. {
74. strPNameAndPValue = strEachCookParts[j];
75. if (strPNameAndPValue != string.Empty)
76. {
77. NameValuePairTemp = strPNameAndPValue.Split('=');
78. if (NameValuePairTemp[1] != string.Empty)
79. {
80. cookTemp.Path = NameValuePairTemp[1];
81. }
82. else
83. {
84. cookTemp.Path = "/";
85. }
86. }
87. continue;
88. }
89.
90. if (strEachCookParts[j].IndexOf("domain", StringComparison.OrdinalIgnoreCase) >= 0)
91. {
92. strPNameAndPValue = strEachCookParts[j];
93. if (strPNameAndPValue != string.Empty)
94. {
95. NameValuePairTemp = strPNameAndPValue.Split('=');
96.
97. if (NameValuePairTemp[1] != string.Empty)
98. {
99. cookTemp.Domain = NameValuePairTemp[1];
100. }
101. else
102. {
103. cookTemp.Domain = strHost;
104. }
105. }
106. continue;
107. }
108. }
109.
110. if (cookTemp.Path == string.Empty)
111. {
112. cookTemp.Path = "/";
113. }
114. if (cookTemp.Domain == string.Empty)
115. {
116. cookTemp.Domain = strHost;
117. }