473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using Session object in Javascript on Win 2003

Rob
Hi,
I'm getting an error on my login page when using Javascript session
object. It works on the development server so I'm wondering if there is
a setting in IIS to allow using sessions on the server.

When the user clicks on the submit button after entering their username
and password, it calls a function (below) and I get an "Object expected"
javascript error.

This is the function:

function ftn_process()
{
var str_uid = document.login.str_uid.value;
var str_pswrd = document.login.str_pswrd.value;
if (str_uid != "" && str_pswrd != "")
{
Session("UserID") = ""
Session("Logged") = "";
Session("userLevel") = -1;
document.forms("login").submit();
}
}

I get the error at Session("UserID");
Does anybody have any ideas on this problem?

Yhanks
Rob
*** Sent via Developersdex http://www.developersdex.com ***
Jan 3 '07 #1
7 7297
VK

Rob wrote:
Session("UserID") = ""
I get the error at Session("UserID");
Does anybody have any ideas on this problem?
Possibly because you didn't define Session function anywhere in your
code.
It has to be a function because you are calling it in the function
contect.

Jan 3 '07 #2
VK

VK wrote:
Rob wrote:
Session("UserID") = ""
I get the error at Session("UserID");
Does anybody have any ideas on this problem?

Possibly because you didn't define Session function anywhere in your
code.
It has to be a function because you are calling it in the function
contect.
Oops... Correction: you cannot assign to function results. This way
Session("UserID") = "";
has no sense whatsoever.

Could you provide a link to get an idea of what are you doing?

Jan 3 '07 #3

Rob wrote:
Hi,
I'm getting an error on my login page when using Javascript session
object. It works on the development server so I'm wondering if there is
a setting in IIS to allow using sessions on the server.

When the user clicks on the submit button after entering their username
and password, it calls a function (below) and I get an "Object expected"
javascript error.

This is the function:

function ftn_process()
{
var str_uid = document.login.str_uid.value;
var str_pswrd = document.login.str_pswrd.value;
if (str_uid != "" && str_pswrd != "")
{
Session("UserID") = ""
Session("Logged") = "";
Session("userLevel") = -1;
document.forms("login").submit();
}
}

I get the error at Session("UserID");
Does anybody have any ideas on this problem?

Yhanks
Rob
Hi

The Session object is a host object (i.e. not native) that is made
available to JavaScript code processed on the server in an ASP
pre-processing page.

Contrary to VK's comment, under ASP I believe the Session object's
properties are accessed using ' ( ) ' notation, so in an ASP page,
Session("UserID") = "" is I think valid.

However, looking at the above code, it looks like you are running this
in a client web page. The ASP Session object cannot be acessed by code
running on the client. It is only available to that JavaScript which
runs on the server **before** the ASP page is sent to the client.

Regards

Julian

Jan 3 '07 #4
Rob
Thanks Julian,

The problem is that this was working on the development server but when
we moved it to production, that's when I get the error so that's why I
thought it was an IIS setting issue.
I would send a link but it's an intranet application.

The page language is javascript as well,
<% @Language="javascript" %>

but my function is within a <scriptblock.

I don't know if that makes a difference.

Regards
Rob

*** Sent via Developersdex http://www.developersdex.com ***
Jan 3 '07 #5
VK
Julian Turner wrote:
Contrary to VK's comment, under ASP I believe the Session object's
properties are accessed using ' ( ) ' notation, so in an ASP page,
Session("UserID") = "" is I think valid.
I meant that this statement is not valid for ECMAScript-compliant
engines including javascript. Whatever is valid for server-side ASP
instructions is beyond of anyone's power but Microsoft.

Jan 3 '07 #6
Rob wrote on 03 jan 2007 in comp.lang.javascript:
Thanks Julian,

The problem is that this was working on the development server but when
we moved it to production, that's when I get the error so that's why I
thought it was an IIS setting issue.
I would send a link but it's an intranet application.

The page language is javascript as well,
<% @Language="javascript" %>

but my function is within a <scriptblock.

I don't know if that makes a difference.
Learn to understand the difference between
server side executed code and clientside executed code.

Serverside code is processed first
and the resulting html [perhaps with client side code]
is sent as a stream to the clientside, the browser mostly,
and the clientside cannot even see the serverside code.

============ test.asp ==================
<% @Language='javascript' %>
<br>
<%
if (7>5) response.write('Hello world');
%>
<br>
<script type='text/javascript'>
document.write('good morning.');
</script>
=========================================

will send this html to the browser:

=======================================
<br>
Hello world
<br>
<script type='text/javascript'>
document.write('good morning.');
</script>
========================================

And the browser will display:

=======================================

Hello world
good morning.
========================================

Session variables are serverside variables,
and only their containing values can be sent to the client.

<%
response.write( session('theName') );
%>

So the session object only exist in the serverside code.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 3 '07 #7
The page language is javascript as well,
<% @Language="javascript" %>

but my function is within a <scriptblock.

I don't know if that makes a difference.

Regards
Rob
The problem is most likely due to a missing runat="server" attribute in
your script tag. Your tag should look like:

<script type="javascript" runat="server">
...
</script>

Cheers
Chad

Jan 3 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
6
by: Shashi | last post by:
I have developed ASP.Net application using .Net 1.1 Framework. When the user clicks image file through Java script I am using my search window as below. QueryString =...
4
by: The Eeediot | last post by:
Hello, folks! I am trying to design a login script / page for a set of administrative functions on my company's Intranet. I need something that is reasonably secure and I've been trying to rack...
12
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.