Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Store a field value from database into a session
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  15:15:09  Show Profile
Can someone help me store a few field values of 1 user into a session variable?

I'm guessing that this would be done when a user logs in. I would like to store a few things like their m_country and m_sex into a couple session variables, so that further in my site (ie my chat room) i can insert the information directly into the chat users profile info. eg:

<applet blah blah>
<param name="username" value="<%= sesison("sesName") %>">
<param name="profile_country" value="<%= sesison("sesCountry") %>">
<param name="profile_sex" value="<%= sesison("sesSex") %>">
<param name="loginstatus" value="autologin">
</applet>

I dont want to have to query the snitz database on my chatpage to get the values cause its not efficient.

-WizzKidd

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!

Edited by - ruirib on 14 April 2003 16:56:29

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 14 April 2003 :  16:56:11  Show Profile  Send ruirib a Yahoo! Message
What is it that you don't know? How to get the values from the DB? How to store them in the session vars?


Snitz 3.4 Readme | Like the support? Support Snitz too

Edited by - ruirib on 14 April 2003 18:46:29
Go to Top of Page

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  17:47:26  Show Profile
I dont know where abouts to get the data from.
I know how to connect to the database and get the rs (recordset) value to a variable, but the record set is not open on the login page, so where can i get the values from?

My only method that i can think of is to open the FORUMS_MEMBERS table, then do a SELECT query on the current logged in username, but I want to avoid having to connect to the database. On the login page, i notice that the fName and fPassword variables are populated (1 from the form, and the other is a mystory to me)

fName = strDBNTFUserName
fPassword = ChkString(Request.Form("Password"), "SQLString")

but i wanna get the country and sex into variables too. surley i dont have to open a recordset on this page? the recordset was obviously opened and closed somewhere prior to the logging in check.

Get what im on about now?

-WizzKidd

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 14 April 2003 :  17:59:57  Show Profile
quote:
Originally posted by Wizz

I dont know where abouts to get the data from.
I know how to connect to the database and get the rs (recordset) value to a variable, but the record set is not open on the login page, so where can i get the values from?

The only way to get data from the database is to query the database.
quote:
surley i dont have to open a recordset on this page? the recordset was obviously opened and closed somewhere prior to the logging in check.
how do you know this? can you find on the page where the recordset was opened? if so, just set your variables there.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  18:13:07  Show Profile
Ok, fair enough!

What Unique Identifier will i select from the databse then? Are usernames unique? or is there someway i can get the current users MEMBER_ID to do my select instead?

eg:
SELECT * FROM FORUM_MEMBERS WHERE MEMBER_ID = 'XXXXXXXX'
or if usernames are unique can i do:
SELECT * FROM FORUM_MEMBERS WHERE M_USERNAME = 'XXXXXXXX'
or alternativly:
SELECT * FROM FORUM_MEMBERS WHERE M_USERNAME = 'XXXXXXXX' AND M_PASSWORD = strEncodedPassword = sha256("" & fPassword)

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!
Go to Top of Page

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  18:25:31  Show Profile
fName = strDBNTFUserName
fPassword = ChkString(Request.Form("Password"), "SQLString")

RequestMethod = Request.ServerVariables("Request_Method")

if RequestMethod = "POST" Then
strEncodedPassword = sha256("" & fPassword)
select case chkUser(fName, strEncodedPassword,-1)
case 1, 2, 3, 4
Call DoCookies(Request.Form("SavePassword"))
strLoginStatus = 1
case else
strLoginStatus = 0
end select

if strLoginStatus = 1 then
'## query database to search for the user that just logged in ##
'## (if the strLoginStstus = 1 then the user is valid, therefore ##
'## re-search for him/her using his/her M_NAME and M_PASSWORD ) ##
strSql = "SELECT * "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE M_NAME = '" & trim(fName) & "' AND "
strSql = strSql & " M_PASSWORD = '" & trim(strEncodedPassword) & "'"

Set dbRs = my_Conn.Execute(strSql)

'## store my session variables from the recordset ##
session("mix_loggedin") = "TRUE"
session("mix_sex") = dbRs("M_SEX")
session("mix_country") = dbRs("M_COUNTRY")

Response.Redirect("/default.asp")
end if
end if


-WizzKidd

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!
Go to Top of Page

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  18:26:38  Show Profile
i think thats it, gonna test it in a sec after my shower. I posted it for the bennifit of others in the future (if it works that is)

-WizzKidd

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 14 April 2003 :  18:45:59  Show Profile  Send ruirib a Yahoo! Message
If you include inc_header.asp, the MemberID variable will give you the Member_ID for the logged in member, which is the primary key for the members table. If a user is logged in, the mlev variable will give you a value > 0.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Wizz
New Member

United Kingdom
70 Posts

Posted - 14 April 2003 :  19:10:47  Show Profile
thanks. i will rewrite it accordingly

www.promotioncity.co.uk - A cost effective solution for Promoters, DJ's and MC's. Clubbing Pics, Chat, Forums, Raving/Clubbing Guide, A-Z Clubs & Winebars listing etc + much more!
Go to Top of Page

jfitz
Junior Member

USA
345 Posts

Posted - 14 April 2003 :  22:12:27  Show Profile
There is a function already being called (chkUser, I think) that happens at login. This is a good place to add code to pull user information because the data base is already open to the user being logged in, and then you don't need a separate data base access for this. We use this to determine whether the user is on probation (all posts moderated) or not.

--Jördan
It's a wasted day if you don't spend at least part of it flying upside down.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.4 seconds. Powered By: Snitz Forums 2000 Version 3.4.07