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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link a condition to a session("UID") ?

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
BE
For example login session("UID") is 10

In my program xyz.asp this test gives 10
Code:
<%response.write session("uid")%>

but the following conditions code does not work
Code:
<%if rsRC("MemberID")=Session("UID") Then%>
       		<p style="color: blue; font-weight: bold; background-color: lightgrey;">  
       <%end if%>

If I manually insert the following code it works
Code:
<%session("uid")=10%>

What am I doing wrong ?
Thanks for tips.
 
I can't see anything *wrong* with your code, but we probably need a bit more context...

I think for debugging, I would try this...

Code:
<%
if rsRC("MemberID")=Session("UID") Then
%>
    <p style="color: blue; font-weight: bold; background-color: lightgrey;">  
<%
else
    response.write "<BR>[" & rsRC("MemberID") & "][" & Session("UID") & "]<BR>"
end if
%>

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Not to be critical, but I tend to break my code out from the HTML stuff to make it clearer and easier to read.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Thanks GriffMG
else
response.write "<BR>[" & rsRC("MemberID") & "][" & Session("UID") & "]<BR>"
Debugging code returns the expected Session("UID") => everywhere - not only 'else'
What else can I investigate in detail?
 


The comparison assumes the Session variable and the recordset column are of the same datatype.

Code:
rsRC("MemberID") = 123456

Session("UID"] = "123456" 

rsRC("MemberID") <> Session("UID"]


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Is it firing the 'else' response line? and if so what is in it?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
This
Code:
<%
Session("UID")="12345678"
mVar = 12345678
IF mVar = Session("UID") then
	response.write "True"
ELSE
	response.write "False"
END IF 
%>

Produces False, you can compare an int with a string...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Sorry GriffMG I don't understand your question : Is it firing (?) the 'else' response line? and if so what is in it?
I saw all rows have the same session("UID") figure (= same as login)
 
Do you get the result from this line

Code:
response.write "<BR>[" & rsRC("MemberID") & "][" & Session("UID") & "]<BR>"

Can you show us the result?



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Code:
response.write "<BR>[" & rsRC("MemberID") & "][" & Session("UID") & "]<BR>"
Code:
response.write "<BR>[" & isnumeric(rsRC("MemberID")) & "][" & isnumeric(Session("UID")) & "]<BR>"

results :
[13][13]
[True][True]

the conditions met but the code does not work (no blue print)
Code:
<p style="color: blue; font-weight: bold; background-color: lightgrey;">

Thanks for tips.
 
Ok

So the two values are equal, every entry in rsRC("MemberID") is equal to Session("UID")

What are you expecting?

Sorry I do not follow

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
GriffMG said:
So the two values are equal, every entry in rsRC("MemberID") is equal to Session("UID")

Results = one example result of a whole series => NOT every entry in rsRC("MemberID") is equal to Session("UID")
[13][13]
[True][True]

This example (as an answer on your question GriffMG) proves
- if both elements [rsRC("MemberID" and Session("UID")] are equal
- and if they are both numeric (questions from MarkSweetland and GriffMG)
then the end result of this example does NOT meet the condition = blue print

GriffMG said:
What are you expecting?
So my initial question (cf. first post) remains : if the condition is met [13][13], why isn't it printed in blue?
(and if I manually insert the following code <%session("uid")=13%> it works)

What else can I check?

 
Right, phew, I get you.

Having achieved a match, the style you have entered doesn't work!
This prints False in Red
Code:
<%
Session("UID")="12345678"
mVar = 12345678
IF Session("UID") = mVar then
%>
<p style="color: blue; font-weight: bold; background-color: lightgrey;"> 
<%
	response.write "True"
ELSE
%>
<p style="color: red; font-weight: bold; background-color: lightgrey;"> 
<%
	response.write "False"
END IF 
%>

This prints true in blue

Code:
<%
Session("UID")="12345678"
mVar = "12345678"
IF Session("UID") = mVar then
%>
<p style="color: blue; font-weight: bold; background-color: lightgrey;"> 
<%
	response.write "True"
ELSE
%>
<p style="color: red; font-weight: bold; background-color: lightgrey;"> 
<%
	response.write "False"
END IF 
%>

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
GriffMG's equation 1 : string <> numeric => equation=False => red (=OK)
Session("UID")="12345678"
mVar = 12345678

GriffMG's equation 2 : string = string => equation=True => blue (=OK)
Session("UID")="12345678"
mVar = "12345678"

my equation : numeric [=true] = numeric [=true] => equation=True => but NOT blue (without manual insertion) - Why ?
Session("UID") = 13
rsRC("MemberID") = 13

Any other possible causes to check?
 
Fixed - Session("UID") converted to data type of MemberID = long integer.
Thanks to MarkSweetland and GriffMG.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top