S
Shapper
Hello,
I have this code in Global.asax:
Sub Session_Start(Sender As Object, E As EventArgs)
Dim cookie As HttpCookie = Request.Cookies("MyCookie")
If Not cookie Is Nothing Then
Response.Write(" * Cookie Exists * ")
If Not cookie.Values("culture") Is Nothing
Response.Write(" * Value Culture Exists Inside Cookie *
")
Session("culture") = cookie.Values("culture")
Thread.CurrentThread.CurrentCulture = New
CultureInfo(cookie.Values("culture"))
Else
Response.Write(" * Value Culture Doesn't Exist Inside
Cookie* ")
cookie.Values.Add("culture", "pt-PT")
Response.Cookies.Add(cookie)
End If
Else
Response.Write(" * Cookie Doesn't Exist * ")
Dim newCookie As HttpCookie = New
HttpCookie("CamaraDosPares")
newCookie.Values.Add("culture", "pt-PT")
newCookie.Expires = #01/01/3000#
Request.Cookies.Add(newCookie)
End If
End Sub
Basicly this shoud work this way:
IF Cookie Exists AND Cookie Value "Culture" Exists THEN
Session("culture") = ...
IF Cookie Exists AND Cookie Value "Culture" Doesn't Exist THEN
Add Culture Value to the existing Cookie.
(NOTE: Cookie have many other values. Culture Values must be
added to the existing ones.)
IF Cookie Doesn't Exist THEN
Create Cookie and place a "culture" value inside it.
Of course I want this code to run when a new session starts.
The code works but strange things happen like:
No Cookie is created.
OR
When Culture value is added to cookie all the other disappear.
This is driving me crazy. I am on this for hours.
Could someone please check it out?
I added Response.Write commands to help following what is going on.
Maybe something stange going on with my OS....I don't know.
Thank You,
Miguel
I have this code in Global.asax:
Sub Session_Start(Sender As Object, E As EventArgs)
Dim cookie As HttpCookie = Request.Cookies("MyCookie")
If Not cookie Is Nothing Then
Response.Write(" * Cookie Exists * ")
If Not cookie.Values("culture") Is Nothing
Response.Write(" * Value Culture Exists Inside Cookie *
")
Session("culture") = cookie.Values("culture")
Thread.CurrentThread.CurrentCulture = New
CultureInfo(cookie.Values("culture"))
Else
Response.Write(" * Value Culture Doesn't Exist Inside
Cookie* ")
cookie.Values.Add("culture", "pt-PT")
Response.Cookies.Add(cookie)
End If
Else
Response.Write(" * Cookie Doesn't Exist * ")
Dim newCookie As HttpCookie = New
HttpCookie("CamaraDosPares")
newCookie.Values.Add("culture", "pt-PT")
newCookie.Expires = #01/01/3000#
Request.Cookies.Add(newCookie)
End If
End Sub
Basicly this shoud work this way:
IF Cookie Exists AND Cookie Value "Culture" Exists THEN
Session("culture") = ...
IF Cookie Exists AND Cookie Value "Culture" Doesn't Exist THEN
Add Culture Value to the existing Cookie.
(NOTE: Cookie have many other values. Culture Values must be
added to the existing ones.)
IF Cookie Doesn't Exist THEN
Create Cookie and place a "culture" value inside it.
Of course I want this code to run when a new session starts.
The code works but strange things happen like:
No Cookie is created.
OR
When Culture value is added to cookie all the other disappear.
This is driving me crazy. I am on this for hours.
Could someone please check it out?
I added Response.Write commands to help following what is going on.
Maybe something stange going on with my OS....I don't know.
Thank You,
Miguel