Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is the session variable getting killed?

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
At the top of my menu, I have some code to check if the user is logged in by way of session variable, and if so, hello User. Otherwise, it will display a login box.
The problem is that when I get to the first place where the session variable would and should be <> &quot;&quot;, the code seems to be killing the session variable, and my error message of if session(&quot;CandID&quot;) = &quot;&quot; then
response.write &quot;You must be logged in to update your profile.&quot;
etc.
fires, even though I know on the page before the session variable was hale and hearty.
Here's the code. Can someone please find my mistake?

<%
if session(&quot;CandID&quot;) <> &quot;&quot; then
dim helloString
helloString = &quot;Hello &quot; & session(&quot;CandID&quot;) & &quot;!&quot;
helloString = helloString & &quot;If you are not &quot; & session(&quot;CandID&quot;) & &quot;please &quot;
helloString = helloString & &quot;<a href='default.shtml'>log in.</a>&quot;
Response.Write helloString
else
%>


<h3>Already a member? <br>Login now.</h3>
<form action=&quot;validatePassword.asp&quot; method=&quot;get&quot; name=&quot;frmLogin&quot;>

<table>
<tr>
<td>Username: </td></tr>
<tr>
<td><input id=&quot;text1&quot; name=&quot;txtUserName&quot;></td></tr>
<tr>
<td>Password: </td></tr>
<tr>
<td><input type=&quot;password&quot; id=&quot;password1&quot; name=&quot;txtPassword&quot;></td></tr>
</table>
<input type=&quot;image&quot; src=&quot;images/img_Submit.gif&quot; value=&quot;Submit&quot; id=&quot;submit1&quot; name=&quot;btnSubmit&quot; WIDTH=&quot;106&quot; HEIGHT=&quot;54&quot;>
</form>

<h3>New User? <a href=&quot;profile.shtml&quot;>Click Here</a> </h3>
<%
end if
%>
 
is the session var being used in a global or in a earlier page. I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
I got it to work, but I'm not quite sure why it didn't work the first time. All I did was change the place where the variable was being set on the page before, from an onClick event to regular page processing.

BTW, I can certainly agree with your sig, and realize that the 15th time is only so sweet because it's the 15th!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top