Forums
This topic is locked
ASP and Sessions (with DmwMX2004)
Posted 29 Nov 2004 19:16:10
1
has voted
29 Nov 2004 19:16:10 Jon Wendzina posted:
This is probably a simple query, but I'm writing an Intranet for my company as we speak. The majority of it is done but I'm having a few issues. I was wondering if anyone can give me some help? <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>Basically I'm using access for my db and dreamweaver mx 2004 for the front end. I have a login page and when the user logs in, it directs to the logged in page. There is a session in there that says
"Welcome XXXXX" Where X is their log in name. How can I then call up other values within a table for a specific user based on their session login?
If you don't understand, let me clarify. I have a table called users. It contains their First Name, Last Name, a link to their "My documents", a Username and a Password. If they login, I want to be able to make sessions only from their relevant part of the database. So if I was to login, it can say 'Hello Jon Wendz' instead of 'hello jonw' which is the login name. I hope this makes some sense...
Regards
Jon!
Replies
Replied 29 Nov 2004 19:26:26
29 Nov 2004 19:26:26 Simon Martin replied:
The login server behaviour sets a session variable called MM_Username which it then checks for on all secured pages. You can use MM_Username to filter a recordset on your secured pages, provided the username is unique, otherwise you'll need to set another session variable with their primary key which means a bit of handcoding in the server behaviour.
Then you can customise each page by using the server behaviour.
e.g. SELECT * from tblUsers WHERE username = MM_Username
or where userID = mySessionID
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Edited by - ganseki on 29 Nov 2004 19:28:22
Then you can customise each page by using the server behaviour.
e.g. SELECT * from tblUsers WHERE username = MM_Username
or where userID = mySessionID
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Edited by - ganseki on 29 Nov 2004 19:28:22
Replied 30 Nov 2004 12:33:29
30 Nov 2004 12:33:29 Jon Wendzina replied:
That is excellent. Every login name is unique - however it's not set to the primary key. I have an AutoNumber as the primary key, will the effect it in any way? I guess I could set it as such, although it may create difficulties with the relationships.
Replied 30 Nov 2004 13:14:50
30 Nov 2004 13:14:50 Simon Martin replied:
As long as every login name is unique then there's no problem using the MM_Username session to filter your recordsets - you will only ever get 1 result returned and that's all the PK would do.
You could set another session variable with the PK if you wanted, but in your case I wouldn't bother as each session variable takes server resources (which is a bad thing)
Creating your relationships wont be affected, just build them in the normal way let the WHERE clause do the filtering e.g.
SELECT *
FROM tblUser u INNER JOIN
tblAccessLevel al ON al.accessID = u.accessID
WHERE u.username = MM_Username
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Edited by - ganseki on 30 Nov 2004 13:16:45
You could set another session variable with the PK if you wanted, but in your case I wouldn't bother as each session variable takes server resources (which is a bad thing)
Creating your relationships wont be affected, just build them in the normal way let the WHERE clause do the filtering e.g.
SELECT *
FROM tblUser u INNER JOIN
tblAccessLevel al ON al.accessID = u.accessID
WHERE u.username = MM_Username
Live the life you love
Love the life you live
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Edited by - ganseki on 30 Nov 2004 13:16:45