?
Solved

Need to Convert JavaScript Session Variable to VB Classic ASP

Posted on 2010-09-17
6
Medium Priority
?
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

719 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