|
| |
|
|
Toolman
Posts: 203 Joined: 3/14/2002 From: United Kingdom Status: offline
|
' Session' values - 12/9/2002 11:34:52
Is it possible to use session values to update a database record. What I need to do is use an ID value(auto generated by access) stored as a session value to call a set of records from a database so that they can be updated by the user logged in (logging in creates the session value " ID" ). Is this possible and does anyone have some example code to play with? Many thanks
_____________________________
Toolman " ....It was like that when I got Here!"
|
|
|
|
Toolman
Posts: 203 Joined: 3/14/2002 From: United Kingdom Status: offline
|
RE: ' Session' values - 12/10/2002 3:30:22
Thanks for the reply guys Spooky - Bobby Hit the nail on the head. What I am trying to do is find a way of giving registered users a way of changing their own password only. To do this I have created an ASP page using the FP2002 Wizard that looks at the users table in the database. I have a link to that page and was trying to use the session variable ID (auto generated by Access) to call the user account from the database into the ASP page and allow them to edit their name and password. Obviously I dont want them to be able to call another persons account, only their own so I thought that using the ID (a unique number field) would be the best way to do it. Bobby - I have tried using the Session value in the database query string but I cannot get it to work. Do you think that as I used the DRW to generate the page I will need to put it on a ' diet' to make it go? Sorry I cannot post a URL for this as it is Intranet and not Internet. Cheers
_____________________________
Toolman " ....It was like that when I got Here!"
|
|
|
|
Doug G
Posts: 1189 Joined: 12/29/2001 From: SoCal Status: offline
|
RE: ' Session' values - 12/10/2002 16:01:41
You shouldn' t use the IIS session key (session.sessionid) as a unique identifier for a user database, because it' s not guaranteed to be unique always, only that at any given time it' s unique among active sessions on the web server. A session key from a closed session may be reused by IIS at a later time for a different user session. I use an autonumber ID in Access to identify each user record, save it in a session variable, and use it to locate that user record in the database. Assuming your login process returns a UserID, you can store the value in a session variable (I think bobby already posted an example but I' m trying to boost my keystroke count :) Session.ThisUserID = rs(" UserID" ) Then, later in another page where con is your active database connection:
<%
dim UID, sq, rs
UID = Session.ThisUserID
sq = " SELECT * FROM UserTable WHERE UserID = " & UID
rs.open con, sq, 3, 3
rs(" Username" ) = " NewUserName"
rs.update
rs.close
set rs = nothing
%>
_____________________________
====== Doug G ======
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|