[SOLVED] ASP Session Variable

This is a discussion on "[SOLVED] ASP Session Variable" within the Classic ASP section. This forum, and the thread "[SOLVED] ASP Session Variable are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 4th, 2007, 04:34
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
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: Select all
    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: Select all
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
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 4th, 2007, 04:54
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: ASP Session Variable

Well.

I manage to solved it here:
Code: Select all
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...
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 4th, 2007, 07:43
welshstew's Avatar
Site Admin

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,713
Blog Entries: 14
Thanks: 4
Thanked 33 Times in 31 Posts
Re: ASP Session Variable

Can you mark the thread as solved please. Cheers.
__________________
WelshStew Site Admin
If you think I've helped, click the "Thanks"
tierney rides tboard - uk site | xtreme wales - extreme clothing
WebForumz - facebook | LinkedIn
Last Blog Entry: Phorm approved for UK rollout (Sep 17th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 4th, 2007, 08:09
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: ASP Session Variable

How to do that?

I have been trying to do that since yesterday....
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 4th, 2007, 08:39
welshstew's Avatar
Site Admin

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,713
Blog Entries: 14
Thanks: 4
Thanked 33 Times in 31 Posts
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 Site Admin
If you think I've helped, click the "Thanks"
tierney rides tboard - uk site | xtreme wales - extreme clothing
WebForumz - facebook | LinkedIn
Last Blog Entry: Phorm approved for UK rollout (Sep 17th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 4th, 2007, 08:52
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
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)
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 5th, 2007, 06:20
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
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
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 10th, 2007, 02:44
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
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
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
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

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 12:22
Session variable errors fogofogo PHP Forum 2 Dec 16th, 2005 12:23
Assign string values to integer values of a session variable Andy K Classic ASP 1 Jul 13th, 2005 08:29
problem with Session variable andrew_perez5 Classic ASP 0 Jan 24th, 2005 03:42
session variable Monie Classic ASP 7 Aug 30th, 2004 03:52


All times are GMT. The time now is 14:16.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42