navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

' Session' values

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> ' Session' values
Page: [1]
 
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!"
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: ' Session' values - 12/9/2002 14:05:31   
Whenever a user enters a site, they are given a unique session id, called session.sessionid
This is one way to recognize the one user for that session, however Im not sure if thats what you mean. Why are you needing a value generated from the database?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Toolman)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: ' Session' values - 12/9/2002 15:00:21   
I think you mean that you want Access to Auto-generate a UserID type number that you can write into a Session variable...

Then that variable can be called on subsequent pages to retreive data from the database..?

Yep, it can be done...

Basically you' re going to open the recordset, just like always... then once you locate the user in the recordset (either via password or email or something...) set the session variable by:
<%
Session(" ID" )=rsA(" ID" )
%>

Where rsA is the name of the recordset, and ID is the name of the field in the DB. The Session(" ID" ) could be anything... Session(" blablabla" ) for example...

When you want to call or update data in the DB for that user, just use something like this in your query:

" Select * From Table where ID = "  & Session(" ID" ) & " ;" 

The ID number has to be set in the database first in order for this to happen... but you' ll want to varify the user first if this is user dependent...

I' ve found it more reliable to grab the last ID# in the table and then do something like:
newID=rsA(" ID" )+1

to get the next number... then insert that number into the DB. Access generated numbers just tend to be a pain in my neck...

Is that helpful?

< Message edited by bobby -- 12/9/2002 12:01:49 PM >


_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Toolman)
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!"

(in reply to Toolman)
bobby

 

Posts: 11394
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: ' Session' values - 12/10/2002 10:37:50   
quote:

I have tried using the Session value in the database query string


Have you set the session variable ahead of time? (I don' t mean to insult your intelligence, but this is where I would start...)

How are you setting it in the query string?

Try setting the session variable to a new variable (like x or varID) then use that variable in the query string...

I' m not sure about DRW syntax, so someone else will need to help us out with that...

(Another good method for identifying users is to use their email address. Since they are unique already you don' t have to worry about two users having the same one. Then you restrict access via a login name and password.)

_____________________________

If con is the opposite of pro, is Congress the opposite of progress?


:)

(in reply to Toolman)
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
======

(in reply to Toolman)
Toolman

 

Posts: 203
Joined: 3/14/2002
From: United Kingdom
Status: offline

 
RE: ' Session' values - 12/11/2002 6:16:53   
Bobby, Doug
Thanks for the help.
I did some searching in the forum and came up with the answer that I needed.
Turns out that my Syntax on the query was incorrect - used single and double quotes the wrong way around.[:j]

Because of problems using the autonumber ID field in Access I have based the page on the UserName variable and that works fine:)

Cheers



_____________________________

Toolman
" ....It was like that when I got Here!"

(in reply to Toolman)
Toolman

 

Posts: 203
Joined: 3/14/2002
From: United Kingdom
Status: offline

 
RE: ' Session' values - 12/11/2002 6:16:53   
Bobby, Doug
Thanks for the help.
I did some searching in the forum and came up with the answer that I needed.
Turns out that my Syntax on the query was incorrect - used single and double quotes the wrong way around.[:j]

Because of problems using the autonumber ID field in Access I have based the page on the UserName variable and that works fine:)

Cheers



_____________________________

Toolman
" ....It was like that when I got Here!"

(in reply to Toolman)
Doug G

 

Posts: 1189
Joined: 12/29/2001
From: SoCal
Status: offline

 
RE: ' Session' values - 12/11/2002 18:43:44   
Glad to hear you got it going. :)

_____________________________

======
Doug G
======

(in reply to Toolman)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> ' Session' values
Page: [1]
Jump to: 1





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