TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
515
47k
About Cookies in MVC
Aug 14 2020 10:56 AM
Hello Everyone,
I am saving Session values in cookies with following code :
HttpCookie AlvloginCookie =
new
HttpCookie(
"AlvLogin"
);
//Set the Cookie value.
AlvloginCookie.Values[
"Name"
] = Session[
"Name"
].ToString();
AlvloginCookie.Values[
"UserAuthKey"
] = Session[
"UserAuthKey"
].ToString();
AlvloginCookie.Values[
"Email"
] = Session[
"Email"
].ToString();
AlvloginCookie.Values[
"UserId"
] = Session[
"UserId"
].ToString();
AlvloginCookie.Path = Request.ApplicationPath;
AlvloginCookie.Expires = DateTime.Now.AddDays(365);
Response.SetCookie(AlvloginCookie);
Response.Cookies.Add(AlvloginCookie);
Using that cookies on page using following code :
Request.Cookies["UserId"].Value;
The cookies are getting created in browser, but it does not last long for 365 days.
It is getting expired after couple fo hours.
Anything I missed or any other suggestion would be really appreciated
Thank you in advance
Reply
Answers (
6
)
How to use owin authentication in .net mvc?
Asp.net partial view in a view not being recognized from within a view