Solved

Need to Convert JavaScript Session Variable to VB Classic ASP

Posted on 2010-09-17
6
466 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
Comment Utility
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
Comment Utility
Is there a way I can write the cookie then with out using JavaScript?
0
 
LVL 3

Expert Comment

by:FreakyEddie
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:DakotaKat
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks so much FreakyEddie
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now