Solved

Need to Convert JavaScript Session Variable to VB Classic ASP

Posted on 2010-09-17
6
471 Views
Last Modified: 2012-05-10
I need a way to modify the code below so that I can set it via VB with Classic asp. Currently it works with java Script, however users with Java Script Turned off loose the functionality. If I change it to VB and Server Side it should work for those users.

<script type="text/javascript">document.cookie='userLanguage=<%=Session("userLanguage")%>'</script>
0
Comment
Question by:DakotaKat
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:FreakyEddie
ID: 33701612
You're allready doing so by using Session("userLanguage")

You set it with
Session("userLanguage") = 1043

and

Retrieve it with
strUserLanguage = Session("userLanguage")
0
 

Author Comment

by:DakotaKat
ID: 33701648
Is there a way I can write the cookie then with out using JavaScript?
0
 
LVL 3

Expert Comment

by:FreakyEddie
ID: 33701675
To write the cookie type in your webpage-code:

Session("userLanguage") = 1043 'for USA

Else please post a bit more code or explain a bit more in how you're using it.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:DakotaKat
ID: 33701722
I have a language selector that works for everyone with Javascript enabled, but for those who have it turned off they can not write the cookie that is read each time a page it loaded to determine the correct language. Below is the code on the current page.

<% If (Instr(Session("pageLanguages"), "US") > 0) Then %>
            <a title="ENGLISH" style="text-decoration:none" href="<%=Request.ServerVariables("SCRIPT_NAME") & nQueryString%>lang=us">
            <img src="images/flags/en.png" alt="ENGLISH">&nbsp;English</a>
            <script type="text/javascript">document.cookie='userLanguage=<%=Session("userLanguage")%>'</script>

I would like to be able to set that document.cookie value using something serverside if possible. I know it will not solve my problem if they have cookies turned off.
0
 
LVL 3

Accepted Solution

by:
FreakyEddie earned 250 total points
ID: 33701835
To set it:
Response.Cookies("userLanguage")=strSetUserLanguage

To retrieve it:
strRetrieveUserLanguage = Request.Cookies("userLanguage")


You can use the cookies when you want it to be stored for a longer time. When you just want the lifetime of a browser-session, you can use sessions.
0
 

Author Comment

by:DakotaKat
ID: 33701913
Thanks so much FreakyEddie
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question