Restricting access to member area in ASPWe can create a member only area in asp by using sessions. Userid of the member is stored in session variable and presence of this session variable is checked at the beginning of each page inside the member area. If session with userid is available then further script execution is allowed, otherwise the script execution is stopped and a message asking the member to login is displayed.
The session for every member is created at login page where a session with userid of the member is created after successful login of the member.
This member area pages links we can display once a member is successfully logged in but members may bookmark the URL of member area and may try to access the member area pages without logging in so session checking is a must for all these restricted pages.
We have to keep this checking if session status at the top of each page, here a better idea is to keep all these code inside one file and include that file at the staring of each page of member area. Like this .. Now inside this check.asp file we will keep the code to check the user session status. Here it is .
You can see in the above code if the Session(“userid”) is not available then IsEmpty function will return true and the code inside the if condition will be executed. The fist line will display the message with a link to login page and the next line Rsponse.End will stop further execution of the page.