Forum Moderators: open
I've set up a subscription section to a bunch of white papers on my site, whereby the visitor has to enter their details into the database in order to access the white papers. This is all working fine, but at the moment there's nothing to prevent people from by-passing this login section and accessing the white papers page direct.
I don't want to password protect the page, just re-direct people to the appropriate one, so is there a chunk of code I could use to achieve this if they've accessed the page directly rather than via the login page, or do I have to delve into the world of htaccess?
Many thanks for any help!
Here are some helpful resources:
http://www.webmasterworld.com/help.cgi?cat=help [webmasterworld.com]
[webmasterworld.com...]
_____________________
You could. But if you know little .htaccess you could use cookies to test whether they logged in. If they enter a valid member name at login.asp, a cookie is set in their browser permitting them access:
To do this put this code where they enter a valid username / password combo is checked:
response.cookies("name")="value"
response.cookies("name").Expires#May 10,2006#
This sets a cookie called name which inside is value and expires May 10 2006.
In private.asp place:
If NOT request.cookies("name") = "value" Then
response.redirect "index.asp"
End If
This checks for the cookie which was set at login.asp and if it's not there it redirects them to a different page and if it is it carries on loading the page content.
Notes: This code is written in asp and will only work if asp is on your server. Please check with your provider if you don't know. All of this code must be place before your <html> tag.
If you do not have a server sided langauge search google for javascript set cookies [google.co.uk]