Regarding Sessions..
-
Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance
Bharath.S Ron
-
Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance
Bharath.S Ron
simply... check in page_load event is session variable is null or not if it is null redirect the page to login..thats all
Sarith...
-
Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance
Bharath.S Ron
Bharath.S.Ron wrote:
I will logout and set the session value to null,
Wrong. You should call
Session.Abandon()
Bharath.S.Ron wrote:
my problem here is when i click back in browser after logging out it is going to page two this should not happen.
You are seeing cached version of your page by browser. In each
page_load
event you need to check session existence. If it's not exist, navigate user to login page. Your session check would be like thisif(Session["UserId"]==null)
{
Response.Redirect("Login.aspx");
}
-
Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance
Bharath.S Ron
You have to check in each page load whether the session is null or not null. If the session value is null means redirect to login page else to the required page.
VanithaVasu
-
Bharath.S.Ron wrote:
I will logout and set the session value to null,
Wrong. You should call
Session.Abandon()
Bharath.S.Ron wrote:
my problem here is when i click back in browser after logging out it is going to page two this should not happen.
You are seeing cached version of your page by browser. In each
page_load
event you need to check session existence. If it's not exist, navigate user to login page. Your session check would be like thisif(Session["UserId"]==null)
{
Response.Redirect("Login.aspx");
}
-
You have to check in each page load whether the session is null or not null. If the session value is null means redirect to login page else to the required page.
VanithaVasu
Hi, The real problem here is that the When he logout then the page is redirects to the Login page but,If he clicks the browser's back buttion then He can view the content of the page. Your Idea --putting some code to page load event will not work here because it comes form the Browser's Cache memory. So it will display. Ok
Naresh Patel
-
When i click the browser back button the page load event is not triggered ,the page will be directly loaded over the browser.
Bharath.S Ron
Bharath.S.Ron wrote:
When i click the browser back button the page load event is not triggered
Yes it won't be fired. But since you are checking Session on page load, he/she can't continue with any other operation. If they click on any button's or refresh the page, it will redirect to login page. You can try disabling the caching too. But I doesn't looks like a good solution to me.
-
Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance
Bharath.S Ron
You can disable caching on the client:
Response.CacheControl = "no-cache";
Response.AddHeader("pragma", "no-cache");
Response.Expires = -1;Then the click on Back will cause a request to the server.
-^-^-^-^-^- no risk no funk ................... please vote ------>
-
You can disable caching on the client:
Response.CacheControl = "no-cache";
Response.AddHeader("pragma", "no-cache");
Response.Expires = -1;Then the click on Back will cause a request to the server.
-^-^-^-^-^- no risk no funk ................... please vote ------>
-
Please refer to the MSDN for information about this methods. The effect is that the Browser does not hold a copy of the page in its cache and therefore requests the page from the server when the user clicks on the back button. And you can react as you wish on the server side - show login screen or whatever you like.
-^-^-^-^-^- no risk no funk ................... please vote ------>
-
Please refer to the MSDN for information about this methods. The effect is that the Browser does not hold a copy of the page in its cache and therefore requests the page from the server when the user clicks on the back button. And you can react as you wish on the server side - show login screen or whatever you like.
-^-^-^-^-^- no risk no funk ................... please vote ------>
Yes you are right, But this method will fail with firefox browser. Any other alternative do you know for firefox ?
-
Yes you are right, But this method will fail with firefox browser. Any other alternative do you know for firefox ?
It's new to me that this approach fails with Firefox :omg: I'll have to check this because this is no good news for my applications! Thanks for the hint.
-^-^-^-^-^- no risk no funk ................... please vote ------>