I would like to seek for help regarding a user authentication that I wanted to accomplish.
Current setup of Main Page:
- Consists of simple display of items
- Basic search functionality
- Login functionality (Username textbox, Password textbox and Login button)
When the user logged in, additional functionality will prompt into the current web page (At this point, it is still working).
Now the problem is, when I clicked the refresh button, the user reverts back to "not logged in" state. What I wanted is, whenever the user clicked the refresh button, the user will still be on "logged in" state.
Additional info: On my ASP page (Main Page), I am instantiating the session variable with this line:
<%
Session["IsLogged"]=0;
%>
And I have an internal script to get the session variable to be available to my external javascript:
<script type="text/javascript" language="javascript">
var isLogged = '<%= Session["IsLogged"] %>';
</script>
My login function is being handled by jquery and .aspx.cs wherein I am setting the session variable when a user logged in with this code:
HttpContext.Current.Session["IsLogged"] = 1;
Can you guys help me out? Thanks.
1 Answer 1
Take the code out
<%
Session["IsLogged"]=0;
%>
and that should work.
If you want the user to log out create a log out page and on the page, logout.asp, in that page do something like
<%
Session.Abandon
%>
The user should also be logged out automtically when he closes his web browser
Comments
Explore related questions
See similar questions with these tags.