Forums
This topic is locked
Time limited user authentication
Posted 06 May 2003 16:07:39
1
has voted
06 May 2003 16:07:39 Andrew williams posted:
Hi People,I want to create a user sign up and login page page where the users rights to access the system expire 3 months after the date they signed up. Anybody know how this would be done?
Edited by - andywill23 on 06 May 2003 16:19:53
Replies
Replied 06 May 2003 16:24:23
06 May 2003 16:24:23 Jonathan Danylko replied:
Best thing to do is in the database, add two fields: SignupDate and LastSignon.
When they first sign on, Create the SignupDate and add it to the database AND add it to the LastSignOn Field also.
When they log in, Update the LastSignOn date Field.
Do the comparison here. If the (LastSignOn-SignOnDate) > 30 then restrict access.
Hope this helps. <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
L8R,
Vitoman, M CIW D, MMCP
When they first sign on, Create the SignupDate and add it to the database AND add it to the LastSignOn Field also.
When they log in, Update the LastSignOn date Field.
Do the comparison here. If the (LastSignOn-SignOnDate) > 30 then restrict access.
Hope this helps. <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
L8R,
Vitoman, M CIW D, MMCP
Replied 06 May 2003 17:18:26
06 May 2003 17:18:26 Vince Baker replied:
Simular principal, but you dont really need to store the last login date.
When they join store the current date.
Each time they login run a check to ensure that the date difference is not more than 3 months.
If it is, redirect to warning page.
To do this, u can use the datediff function in your recordset. Let me know if you need some code examples for this.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 06 May 2003 17:19:06
When they join store the current date.
Each time they login run a check to ensure that the date difference is not more than 3 months.
If it is, redirect to warning page.
To do this, u can use the datediff function in your recordset. Let me know if you need some code examples for this.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 06 May 2003 17:19:06
Replied 06 May 2003 17:21:00
06 May 2003 17:21:00 Andrew williams replied:
If you could show me some code examples it would be much appreciated.
Thanks
Thanks
Replied 06 May 2003 17:32:21
06 May 2003 17:32:21 Vince Baker replied:
create a page that will beused to check the user info.
send the username and apssword from your login page to the check page.
Filter a first recordset to check if the username and password are correct as you will want to give a different error for this and for if they are correct but the date has expired.
Add this code to your page under the recordset code:
<% If rsRecordset1name.eof and rsRecordset1name.bof then
response.redirect("badusername.asp"
end if%>
That will go to an error page telling them the username or password is incorrect.
next, we need to check the date:
Add another recordset to the page and use the following example to filter the date:
Select idfieldname
from yourtablename
where DateDiff(mm,StartDateFileName, getdate()) < 3
IF the recordset is empty then the user has had the account for more than 3 calendar months.
add this code after the second recordset
<%
If recordset2.eof and recordset2.bof then response.redirect("expired.asp" else response.redirect("loginsuccessful.asp" end if %>
Change the page names and field names as appropriate.....
good luck
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
send the username and apssword from your login page to the check page.
Filter a first recordset to check if the username and password are correct as you will want to give a different error for this and for if they are correct but the date has expired.
Add this code to your page under the recordset code:
<% If rsRecordset1name.eof and rsRecordset1name.bof then
response.redirect("badusername.asp"
end if%>
That will go to an error page telling them the username or password is incorrect.
next, we need to check the date:
Add another recordset to the page and use the following example to filter the date:
Select idfieldname
from yourtablename
where DateDiff(mm,StartDateFileName, getdate()) < 3
IF the recordset is empty then the user has had the account for more than 3 calendar months.
add this code after the second recordset
<%
If recordset2.eof and recordset2.bof then response.redirect("expired.asp" else response.redirect("loginsuccessful.asp" end if %>
Change the page names and field names as appropriate.....
good luck
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 06 May 2003 18:46:05
06 May 2003 18:46:05 Andrew williams replied:
HI thanks for all the help.
I get the following error
Undefined function 'getdate' in expression.
In the second recordset
I get the following error
Undefined function 'getdate' in expression.
In the second recordset
Replied 06 May 2003 19:07:25
06 May 2003 19:07:25 Andrew williams replied:
This is what i have for the second recordset
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_tissue1_STRING
Recordset2.Source = "SELECT ID FROM users where DateDiff(mm,SignupDate,getdate()) < 3"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
If recordset2.eof and recordset2.bof then response.redirect("expired.asp" else response.redirect("loginsuccessful.asp" end if %>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_tissue1_STRING
Recordset2.Source = "SELECT ID FROM users where DateDiff(mm,SignupDate,getdate()) < 3"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
If recordset2.eof and recordset2.bof then response.redirect("expired.asp" else response.redirect("loginsuccessful.asp" end if %>
Replied 07 May 2003 09:30:08
07 May 2003 09:30:08 Vince Baker replied:
Are you using MySQL / SQL 7 / SQL 2000 / MS Access ?
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 07 May 2003 11:47:02
07 May 2003 11:47:02 Andrew williams replied:
Im using access to test on and then i'll be using mysql when it goes on the web
Replied 07 May 2003 11:54:59
07 May 2003 11:54:59 Vince Baker replied:
rather than using getdate() try date()
there are some function syntax differences between the different dbs
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
there are some function syntax differences between the different dbs
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 07 May 2003 17:27:45
07 May 2003 17:27:45 Andrew williams replied:
Thats cool, got it sussed now.
Ive got another one for you, what i want to do is restrict access to one page so the user can only view it once per day, would the best way to do this be with cookies?
Ive got another one for you, what i want to do is restrict access to one page so the user can only view it once per day, would the best way to do this be with cookies?
Replied 07 May 2003 17:33:45
07 May 2003 17:33:45 Vince Baker replied:
the only problem with a cookie is that the user can turn it off...
I would create a table that logs the visit date and the username and again using the datediff but this time as:
datdiff(hh, lastloggeddate, now()) < 24
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 07 May 2003 17:34:28
I would create a table that logs the visit date and the username and again using the datediff but this time as:
datdiff(hh, lastloggeddate, now()) < 24
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 07 May 2003 17:34:28