J
Jason Williard
I am trying to implement several website translations. In doing so, a cookie
is set so upon return to the site, they are automatically redirected. If the
language is set to something other than "en" the page should redirect to
/lang/LANGUAGE.
To set the language, there is a drop-down menu, or the user can append
?lang=LANGUAGE to the end of the URL.
Below is the code that I have so far.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script runat="server">
Dim page_path As String
sub Page_Load(Sender as Object, e as EventArgs)
Dim lang As String
Dim setlang As String
if ( Request.Querystring("lang") <> "" )
setlang = Request.Querystring("lang")
end if
if ( Request.Querystring("lang") <> "" )
lang = Request.Querystring("lang")
else if ( Response.Cookies("lang").Value <> "" )
lang = Response.Cookies("lang").Value
end if
Response.Write("Hello")
'Response.Write(lang)
Response.Write(Response.Cookies("lang").Value)
if ( setlang <> "" )
Response.Cookies("lang").Value = lang
Response.Cookies("lang").Expires = DateTime.Now.AddMonths(24)
end if
if ( lang <> "" AND lang <> "en" )
Response.Redirect("/lang/" & lang & Request.ServerVariables("URL"))
end if
end sub
</script>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
What works:
- When the user selects the language, it redirects them to the correct page
and sets the cookie.
The problems thus far:
- When the user returns to the main page, the cookie is deleted and they are
not redirected.
Any assistance would be appreciated.
Thank You,
Jason Williard
is set so upon return to the site, they are automatically redirected. If the
language is set to something other than "en" the page should redirect to
/lang/LANGUAGE.
To set the language, there is a drop-down menu, or the user can append
?lang=LANGUAGE to the end of the URL.
Below is the code that I have so far.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script runat="server">
Dim page_path As String
sub Page_Load(Sender as Object, e as EventArgs)
Dim lang As String
Dim setlang As String
if ( Request.Querystring("lang") <> "" )
setlang = Request.Querystring("lang")
end if
if ( Request.Querystring("lang") <> "" )
lang = Request.Querystring("lang")
else if ( Response.Cookies("lang").Value <> "" )
lang = Response.Cookies("lang").Value
end if
Response.Write("Hello")
'Response.Write(lang)
Response.Write(Response.Cookies("lang").Value)
if ( setlang <> "" )
Response.Cookies("lang").Value = lang
Response.Cookies("lang").Expires = DateTime.Now.AddMonths(24)
end if
if ( lang <> "" AND lang <> "en" )
Response.Redirect("/lang/" & lang & Request.ServerVariables("URL"))
end if
end sub
</script>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
What works:
- When the user selects the language, it redirects them to the correct page
and sets the cookie.
The problems thus far:
- When the user returns to the main page, the cookie is deleted and they are
not redirected.
Any assistance would be appreciated.
Thank You,
Jason Williard