473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cookies & Redirection

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

Nov 18 '05 #1
1 1490
i think you forget to add cookie

HttpCookie cookie = null;
cookie = HttpContext.Current.Request.Cookies["aaa"];
make the cookie settings and afrer this register the cookie
HttpContext.Current.Response.Cookies.Add(cookie);

Hope Helps
Cheers

"Jason Williard" wrote:
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karl | last post by:
Hi there! I have a big Problem with some Javascript: On a website, i want to paste some "confirm", if the visitor's browserlanguage is not "de". when he confirm, he'll be redirected to the...
3
by: Peter Row | last post by:
Hi, I better get the background stuff out the way first, so here goes: - Porting a VB6 webclass app to VB.NET using HttpHandlers and FormsAuthentication - When someone visits my site...
2
by: Goober | last post by:
I have an application where we have a limited number of users and a set requirement for web access. An app that I have inherited uses cookies to set certain values (i.e. what would correspond to...
9
by: SHarris | last post by:
Hello, In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet Explorer 6+. 1. Using C# in an ASP.NET...
16
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have...
12
by: Don Juan | last post by:
I have a simple html document I have been using for some time on my (i.e.) abc.com domain that uses cookies. I recently purchased a new domain name and set up a service to redirect my new domain...
3
by: Advo | last post by:
is there any reason why i can view a page at work (which is on our server) yet when i view it online from the domain name (some pages are hosted, some are running off our server) i get the message:...
7
by: Control Freq | last post by:
Hi, Apologies of you have heard this many times before, but I don't know if this is a .NET problem or javascript, or something else. I am using IE6 to view pages from a corporate web server...
14
by: vjayis | last post by:
Hi i m using cookies to store data in an form containing textfields and using the following codes., <?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.