Iam using custom object to store user information. When user logged in am storing username in cookies. So, user user logged into home page and access their information using cookie value.
Once user click on log out button, am clearing cookie values.
If user logs in,closes webpage, then again open the same webpage, user is still logged in. This is working fine until user shut down/restart the system.
Code snippet:
Cookie usernameCookie= new Cookie('uname',username,null,-1,false);
ApexPages.currentPage().setCookies(new Cookie[]{usernameCookie});
PageReference myHome= Page.HOME;
myHome.setRedirect(true);
return myHome;
Once user shut down/restart the system and then open the same webpage, user is logged out(which mean cleared the cookies).
For example, if user logs in,closes webpage, then days or weeks later, user is still logged in when open the same webpage.
How can i maintain the cookie values up to 1 month or until user logs out.
Any help required.