473,779 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Sende r as Object, e as EventArgs)

Dim lang As String
Dim setlang As String

if ( Request.Queryst ring("lang") <> "" )
setlang = Request.Queryst ring("lang")
end if

if ( Request.Queryst ring("lang") <> "" )
lang = Request.Queryst ring("lang")
else if ( Response.Cookie s("lang").Val ue <> "" )
lang = Response.Cookie s("lang").Val ue
end if

Response.Write( "Hello")
'Response.Write (lang)
Response.Write( Response.Cookie s("lang").Value )
if ( setlang <> "" )
Response.Cookie s("lang").Val ue = lang
Response.Cookie s("lang").Expir es = DateTime.Now.Ad dMonths(24)
end if

if ( lang <> "" AND lang <> "en" )
Response.Redire ct("/lang/" & lang & Request.ServerV ariables("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 1510
i think you forget to add cookie

HttpCookie cookie = null;
cookie = HttpContext.Cur rent.Request.Co okies["aaa"];
make the cookie settings and afrer this register the cookie
HttpContext.Cur rent.Response.C ookies.Add(cook ie);

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(Sende r as Object, e as EventArgs)

Dim lang As String
Dim setlang As String

if ( Request.Queryst ring("lang") <> "" )
setlang = Request.Queryst ring("lang")
end if

if ( Request.Queryst ring("lang") <> "" )
lang = Request.Queryst ring("lang")
else if ( Response.Cookie s("lang").Val ue <> "" )
lang = Response.Cookie s("lang").Val ue
end if

Response.Write( "Hello")
'Response.Write (lang)
Response.Write( Response.Cookie s("lang").Value )
if ( setlang <> "" )
Response.Cookie s("lang").Val ue = lang
Response.Cookie s("lang").Expir es = DateTime.Now.Ad dMonths(24)
end if

if ( lang <> "" AND lang <> "en" )
Response.Redire ct("/lang/" & lang & Request.ServerV ariables("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
1548
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 english-translation of this page. to store this information, because it's ugly to ask on every single visit, if he want to switch to the translation.
3
7886
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 unbeknown to them they are automatically logged in as a guest via the .NET forms authentication.
2
3034
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 session variables in regular ASP) that we use to run reports from a SQL database and display them in a web browser. In doing some testing, I noticed that the cookies would remain there for previous used (if I signed into our app as user 1 and...
9
3061
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 application, how can we code the project to check to make sure the browser accepts cookies? 2. Where would we put this code? In Global.asax? 3. Using C# in an ASP.NET application, how can we code the project to detect and make sure the browser...
16
11056
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 read documents on the CookieCollection property of HttpWebRequest. Currently, I have the functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest; however, upon further inspection of the returning...
12
7786
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 (i.e.) xyz.com to a sub-directory of the abc.com domain. In other words, when someone goes to URL xyz.com, they really end up in abc.com/xyz directory but the MSIE browser says they are xyz.com. The problem is that cookies quit working in this...
3
9471
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: "Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked."
7
2616
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 through internet, not VPN. But, the I use a webhop service, so the URL I use is silently redirected to another place. I think this is because the company uses dynamic IP addresses for the server. Anyway, I am trying to use a cookie to remember user...
14
5222
by: vjayis | last post by:
Hi i m using cookies to store data in an form containing textfields and using the following codes., <?
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.