473,385 Members | 2,243 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,385 software developers and data experts.

session variable problem

Hi guys,

I’m facing some problem can u solve it.

Problem is:
I’m giving user Id and password in (Login_sess.asp) and submit it to page
(sess_test.asp). I am setting session variable (session(“Sin”)=”Yes”) just
before redirecting to the same page, but in first time I do not received the
value of session variable when I redirect it, when I execute this process
second time or redirect it only with the page name (sess_test.asp) it
receives session value.

Can you tell me what’s the problem?
I’ve to receive session value in first time and have to redirect with
compete URL
Login_sess.asp (Page is)

<%@ Language=VBScript %>
<html><head>
<title>Login </title>
</head>
<h1 align=center>Login in Your Account </h1>
<BODY>
<form name=login method=post action=sess_test.asp >
<table width=40%>
<tr><td colspan=2>Type Your ID and Password</td></tr>
<tr><td>Enter Your ID</td><td><INPUT type="text" id=txtUID name=txtUID
</td></tr>

<tr><td>Password </td><td><INPUT type="text" id=txtPwd name=txtPwd ></td></tr>
</table>

<table width=40%><tr><td align=center><INPUT type="submit" value="Submit"
id=submit name=submit>
&nbsp&nbsp <INPUT type="reset" value="Reset" id=reset name=reset >
</td></table>
</form></BODY></HTML>
Sess_test.asp (file is)
<%@ Language=VBScript %>
<html><head><title>Main Page </title></head>
<body><form method=get>
<%Response.Write "session Variable =" & Session("Sin")
if Request("txtUID") <> "" then
Session("Sin")="Yes"
Response.Redirect "http://localhost/sg/sess_test.asp"
'Response.Redirect "sess_tes.asp"
end if %>
<br><A href="Login_sess.asp">Sin In</A>
</body></form>
</HTML>

regards,
farooq



Jul 22 '05 #1
1 1879
Until you redirect, you cannot grab the session variable, as it is set in a
session (server) cookie and sent to the client. Once you do the
Response.Redirect, the cookie value is sent with the Request. Then, you can
get it.

I am not sure what you are trying to do architecturally, however. If you
want to check if a user is logged in (able to surf pages), create an include
..asp file with the

if not Session("Sin") = "Yes" then
'Redirect to login
End If

This forces every page to redirect to logon until user is logged in (or
every page with the include). Avoid this script on the login pages.

Hope this makes sense.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"farooqazeem" wrote:
Hi guys,

I’m facing some problem can u solve it.

Problem is:
I’m giving user Id and password in (Login_sess.asp) and submit it to page
(sess_test.asp). I am setting session variable (session(“Sin”)=”Yes”) just
before redirecting to the same page, but in first time I do not received the
value of session variable when I redirect it, when I execute this process
second time or redirect it only with the page name (sess_test.asp) it
receives session value.

Can you tell me what’s the problem?
I’ve to receive session value in first time and have to redirect with
compete URL
Login_sess.asp (Page is)

<%@ Language=VBScript %>
<html><head>
<title>Login </title>
</head>
<h1 align=center>Login in Your Account </h1>
<BODY>
<form name=login method=post action=sess_test.asp >
<table width=40%>
<tr><td colspan=2>Type Your ID and Password</td></tr>
<tr><td>Enter Your ID</td><td><INPUT type="text" id=txtUID name=txtUID
</td></tr>

<tr><td>Password </td><td><INPUT type="text" id=txtPwd name=txtPwd ></td></tr>
</table>

<table width=40%><tr><td align=center><INPUT type="submit" value="Submit"
id=submit name=submit>
<INPUT type="reset" value="Reset" id=reset name=reset >
</td></table>
</form></BODY></HTML>
Sess_test.asp (file is)
<%@ Language=VBScript %>
<html><head><title>Main Page </title></head>
<body><form method=get>
<%Response.Write "session Variable =" & Session("Sin")
if Request("txtUID") <> "" then
Session("Sin")="Yes"
Response.Redirect "http://localhost/sg/sess_test.asp"
'Response.Redirect "sess_tes.asp"
end if %>
<br><A href="Login_sess.asp">Sin In</A>
</body></form>
</HTML>

regards,
farooq




Jul 22 '05 #2

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

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.