Doubt on Cookie - asp.net 2.0
-
hi, currently i m using asp.net 2005 (framework 2.0) i m going to use the cookie for the 1st time in my project (its intranet productivity tool). i need some clarifications... 1. Can we go with Sessions or Cookies? which is best one? 2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one. 3. Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table? help me plz - KARAN
-
hi, currently i m using asp.net 2005 (framework 2.0) i m going to use the cookie for the 1st time in my project (its intranet productivity tool). i need some clarifications... 1. Can we go with Sessions or Cookies? which is best one? 2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one. 3. Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table? help me plz - KARAN
Karan_TN wrote:
1. Can we go with Sessions or Cookies? which is best one?
You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.
Karan_TN wrote:
2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.
One need to give specific time to
Expires
property so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are calledPersistent cookies
, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET CookiesKaran_TN wrote:
Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?
For this, use session There is two method in Global.asax file one is
Session_Start
and another isSession_End
.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can useSession_End
and you can get all those values that you said and can update in datatbase from here only. Let me know if any issueCheers!! Brij Check my latest Article :Exploring ASP.NET Validators
modified on Tuesday, April 20, 2010 2:23 AM
-
Karan_TN wrote:
1. Can we go with Sessions or Cookies? which is best one?
You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.
Karan_TN wrote:
2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.
One need to give specific time to
Expires
property so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are calledPersistent cookies
, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET CookiesKaran_TN wrote:
Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?
For this, use session There is two method in Global.asax file one is
Session_Start
and another isSession_End
.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can useSession_End
and you can get all those values that you said and can update in datatbase from here only. Let me know if any issueCheers!! Brij Check my latest Article :Exploring ASP.NET Validators
modified on Tuesday, April 20, 2010 2:23 AM
-
thanks a lot brij. got cleared with all my doubts. As per your guidance, i will go with sessions itself and take care to remove it at proper place to utilize the memory :) hope i m right. THANKS A LOT!
your most welcome :)
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
Karan_TN wrote:
1. Can we go with Sessions or Cookies? which is best one?
You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.
Karan_TN wrote:
2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.
One need to give specific time to
Expires
property so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are calledPersistent cookies
, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET CookiesKaran_TN wrote:
Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?
For this, use session There is two method in Global.asax file one is
Session_Start
and another isSession_End
.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can useSession_End
and you can get all those values that you said and can update in datatbase from here only. Let me know if any issueCheers!! Brij Check my latest Article :Exploring ASP.NET Validators
modified on Tuesday, April 20, 2010 2:23 AM
Brij wrote:
for details in viewstate, have a lookBeginner's Guide To ASP.NET Cookies
Small Correction Brij, It should be "For details of
Cookies
" notViewState
:laugh:Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Brij wrote:
for details in viewstate, have a lookBeginner's Guide To ASP.NET Cookies
Small Correction Brij, It should be "For details of
Cookies
" notViewState
:laugh:Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
Thanks for pointing it out. Updated :) Anyways that is your article only :)
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
modified on Tuesday, April 20, 2010 2:57 AM
-
Thanks for pointing it out. Updated :) Anyways that is your article only :)
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
modified on Tuesday, April 20, 2010 2:57 AM
Yes. Thanks :thumbsup:
Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.