Just started using ASP.. At the starting of the page we need to check that only logged in member should access. In PHP to check if session exist or not we use isset() . Similarly what is the equivalent function for checking session in ASP? There is a function isnull but I doubt is it a better way for checking session presence? IsNothing(Session("UserName")) this function is giving me error message. I will write a common header file and use it for different files inside member area.
if obj is Nothing should work, but a trick I always use in asp (and .NET) is the trim. trim auto-casts as String and removes spaces so you could do: If trim(Session("UserName")) = "" then ' Redirect to Login page end if
You should look at ASP.NET 2.0. It has built in features to create logged in views for websites...and user/role management. Good stuff to check out. session timeouts can be controlled through the web.config
tonyrocks: yes, the memberships and roles are a beautiful thing if you don't want a custom authentication system - they make it pretty sound and include strongly typed elements for you to directly hook into!
OH yes! I dig it completely. I've even been able to use MS Access as the user/role provider (since some hosting companies will not let you use SQL SErver Express...which handles users/roles by default)
I think you are bluffing my friend... to setup the standard memberships it requires Stored Procedurs which are only offered in SQL Server or SQL Server express (not access) - but hell... I could be wrong I haven't touched access since the version included in office pro 2003 Please enlighten me good sir.
I forgot to mention that I am not searching for solution in Dot Net. It is in pure ASP. Also I am not looking toward any database here. I will authenticate and then create session and redirect to member area. Now inside member area I have to ensure session(“useridâ€) is valid or not. Checking for a null testing or testing like If trim(Session("UserName")) = "" then is enough ?
I am a C# person. Based on that, you have to also check for Null value(Nothing in asp I guess) so you have to do something like this(in C# for example): try { if(Session["userName"]==null) { //do something } else if(Session["userName"].ToString().Trim()=="") { //do something } else { String userName=Session["userName"].ToString(); //check validity } } catch(Exception ex) { //fetch exception }