Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Reply
 
LinkBack Thread Tools
Old October 4th, 2007, 12:34 AM   #1
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Exclamation [SOLVED] ASP Session Variable

I know this sounds simple to you guys, but I can't find anywhere in the internet on how to solve this.

Basically, I have a login page..
and a verify.asp page which will set the session variable to the user username:
Code:
    if rs("password") = Password then
        Session("name") = Request.Form("txtUsername")
        ......
        ......
        Response.Redirect("protectedpage.asp")
Here is the question:
In the protectedpage.asp page, I want to perform an update statement reffering to the username, something like this:
Code:
If Session("name") = "" Then
    Response.Redirect("login.asp")
Else
    Dim cn,sql,rightnow,user,mySessionID
    rightnow = date()
    mySessionID = "this part i want to pull the session value but I dont know the format?"
        Set cn = Server.CreateObject("ADODB.Connection")
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("db/users.mdb")
        Set sql = cn.Execute("UPDATE userlist SET LastActive = " & rightnow & " WHERE username =  "this part??" ")

End If
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 4th, 2007, 12:54 AM   #2
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Re: ASP Session Variable

Well.

I manage to solved it here:
Code:
Set sql = cn.Execute("UPDATE userlist SET LastActive = " & rightnow & " WHERE username =  '" + Session("name") + "'")
what is the different between this two?
'" + Session("name") + "'
'" & Session("name") & "'

either one will work...
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 4th, 2007, 03:43 AM   #3
Elite Veteran
SuperMember
 
welshstew's Avatar
 

Join Date: May 2007
Location: inside the outside
Posts: 3,909
Blog Entries: 14
Thanks: 9
Thanked 40 Times in 38 Posts
Rep Altering Power: 0 welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute
Re: ASP Session Variable

Can you mark the thread as solved please. Cheers.
__________________
WelshStew
extreme sports clothing and t-shirts | twitter| web design
welshstew is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 4th, 2007, 04:09 AM   #4
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Re: ASP Session Variable

How to do that?

I have been trying to do that since yesterday....
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 4th, 2007, 04:39 AM   #5
Elite Veteran
SuperMember
 
welshstew's Avatar
 

Join Date: May 2007
Location: inside the outside
Posts: 3,909
Blog Entries: 14
Thanks: 9
Thanked 40 Times in 38 Posts
Rep Altering Power: 0 welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute
Re: ASP Session Variable

On my view you open up the thread you started, go to thread tools, and then there should be a option to mark thread as solved.

Stew
__________________
WelshStew
extreme sports clothing and t-shirts | twitter| web design
welshstew is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 4th, 2007, 04:52 AM   #6
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Re: ASP Session Variable

Quote:
Originally Posted by welshstew View Post
On my view you open up the thread you started, go to thread tools, and then there should be a option to mark thread as solved.

Stew
Maybe it's on the new theme. I can't find the option to mark thread as solved?
Attached Images
File Type: png Thread Tools.png (5.9 KB, 15 views)
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 5th, 2007, 02:20 AM   #7
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Re: ASP Session Variable

Strange thing happen!

When I logged on to my page successfully, it will capture the date and time and save it to the database.

In the success.asp page (after successfully logged in) I will display the date and time too but when I click the refresh button, the date keeps on updating real time according to the current time.

Can that be fixed a date and time value?
I am using now() function to capture the date and time and save it to the database.

Thanks
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 9th, 2007, 10:44 PM   #8
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Re: ASP Session Variable

Yeah. I solved it.
Don't create a recordset in the page where you display that time from the database.
Don't perform the sql statement in the page where you will display the time..
Quote:
Originally Posted by monie View Post
Dim user
user = Session("name")
Set sql = cn.Execute("UPDATE userlist SET LastActive = " & rightnow & " WHERE username = '" & user & "')
Create them inside the verify.asp page!
login.asp > verify.asp > success.asp
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing a session variable when clicking a link? Crow555 Classic ASP 0 May 15th, 2008 08:22 AM
Session variable errors fogofogo PHP 2 December 16th, 2005 08:23 AM
Assign string values to integer values of a session variable Andy K Classic ASP 1 July 13th, 2005 04:29 AM
problem with Session variable andrew_perez5 Classic ASP 0 January 23rd, 2005 11:42 PM
session variable Monie Classic ASP 7 August 29th, 2004 11:52 PM


Search Engine Optimization by vBSEO 3.2.0 RC8