dhj Posted January 2, 2004 Posted January 2, 2004 hi i need to do something as follows In my web application when a user loged in through the login page i need to remember their name and wanna display their name in every page they are visiting (like hotmail does) i tried 2 methodes to do this, 1 is, put name in the cookies when a user logged in and display that in each and every page . In Application_End clear the cookies other method was to use a session variables both this methods were woking fine but my problem is the pages don't refresh properly say i logged in as user A . First Time it is working fine and all the pages displays A. then i logged out and logged in as B. but still the name displays as A. if i press F5 and refresh it'll display B correctly. i used " <meta http-equiv="Pragma" content="no-cache"> " to refresh the page too but still it's not comming as i want so if anyboday have an idea about this pls help i'm using .net C# environment to develop my web application Thank you Quote
prakash Posted January 2, 2004 Posted January 2, 2004 Check this out Inseted of "Application_End clear the cookies" clear the cookie at session end Quote
dhj Posted January 4, 2004 Author Posted January 4, 2004 hi prakash thx for the reply i tried that method too but it didn't work any ideas? Quote
sharpcoder Posted January 6, 2004 Posted January 6, 2004 (edited) When it comes to user handling the ideal solution in .NET is Forms Authentication. Normally it creates an encrypted cookie containing the user name of the current user (again ideal for your needs). And if you want to store other values as well (user id, first name, last name, address, what ever...) you can extend the class and add your own get/set properties. THis wasn't and answer to your question (sorry for that) but with Forms Auth. everything comes free and you will not have to bother about the thing you described above. Otherwise... how do you log out? By a button or by closing the browser window? If the latter is true, I think you must destroy the old cookie, NOT when the user signs out, but when he signs IN. Edited January 6, 2004 by sharpcoder Quote
AsifCh Posted January 7, 2004 Posted January 7, 2004 The Label on which you are displaying the User Name have the property of EnableViewState set to True Make it To false and in the page load event of every page use the code to set the name of the user on this label. It works just fine. Quote Asif Raza Ashraf Senior Software Engineer Electronic Solutions Pakistan Islamabad
dhj Posted January 9, 2004 Author Posted January 9, 2004 hi all thank u very much for replying me i found a answer by my own i set cookies expired as at minDateTime (least possible date) in the Application end now it 's working fine Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.