473,462 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1881
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...
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:
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.