Need to Convert JavaScript Session Variable to VB Classic ASP

Posted on 2010-09-17
Medium Priority
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>
Question by:DakotaKat
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

Expert Comment

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

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


Retrieve it with
strUserLanguage = Session("userLanguage")

Author Comment

ID: 33701648
Is there a way I can write the cookie then with out using JavaScript?

Expert Comment

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

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.

Accepted Solution

FreakyEddie earned 1000 total points
ID: 33701835
To set it:

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.

Author Comment

ID: 33701913
Thanks so much FreakyEddie

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