473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

about last login date in cookies

123 100+
How to update stored cookies value without change the cookies expired date?

when I login on monday, I have use "remember me for 1 week" to store my login in cookies with my last login date(monday). so next day(tuesday), when I access the site, i don';t need to login again and it show my last login date(monday).

However, if I access the page in Fri, it still show me my last login on Monday.
How to modify the cookies to show correct last access date?
Apr 13 '10 #1
5 3278
chathura86
227 100+
Please post the code you are using to set the cookie, it may be helpful.
Apr 13 '10 #2
perhapscwk
123 100+
Expand|Select|Wrap|Line Numbers
  1.  $info = base64_encode("$userid|$username|$password|$ipaddress|$lastlogin_date|$lastlogin_time");
  2.                  if (isset($remember)){
  3.                      setcookie("user","$info",time()+1209600); 
  4.                  }
thanks.
Apr 13 '10 #3
chathura86
227 100+
well on the next login you have to update the $lastlogin_date and $lastlogin_time

by the way it is not a good idea to store the password in a cookie

Regards
Apr 13 '10 #4
perhapscwk
123 100+
if update the last login date and time, the cookies expired period will update
as well, how to update cookies without chnage it's expired time?
Apr 14 '10 #5
chathura86
227 100+
you have to calculate and subtract the time and reset cookie with the new time
because there is no way to get the expire date from the cookie (as far as i know)

so the easiest method is store the last login date in db, or you can set the expire date also in the cookie and use that to set the expire date

eg
Expand|Select|Wrap|Line Numbers
  1. $expire = time()+1209600;
  2.  
  3.  $info = base64_encode("$userid|$username|$password|$ipaddress|$lastlogin_date|$lastlogin_time|$expire");
  4. if (isset($remember)){
  5.        setcookie("user","$info",$expire); 
  6. }
  7.  
so the next time he logs in you can get the expire date and set the cookie with the $expire time so the expire date will not change

Regards
Apr 14 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Simon | last post by:
Hi, I have a Login.php page that logs the user in and out. I has two forms within the page, (depending on what we are trying to do), either one to log in or out. The form calls itself using a...
1
by: J. Muenchbourg | last post by:
I need to set a cookie on a user after they have logged in. I want to use just the user's login name , since that is a unique field. If rsPersonIDCheck.EOF Then Session("blnValidUser") = False...
3
by: Eşref DURNA | last post by:
My Aim is to make a windows application download which support session and cookies. There is a web site which gives images as links like this...
0
by: Mach Runner | last post by:
I am implementing a secure website using the ASP.NET FormsAuthentication model. I have taken the simplest code examples from MSDN (login.aspx,default.aspx, web.config) but cannot get proper...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
6
by: =?Utf-8?B?S2VsbHk=?= | last post by:
We just switched our web application from .NET 1.1 to 2. Once client can't login out of several that have been successful. They enter a correct user name and password, click the login button and...
3
by: Inny | last post by:
I want To offer a login Option, two Checkboxs, 1 labeled 'normal' the other labeled 'Forever'. I want to assign the check boxes to switch between the cookie script below (normal) and An altered...
4
idsanjeev
by: idsanjeev | last post by:
sir i am creating a page for logout but problems is here if user is logout and click on standard back button then go on previous page so how can restricted it if user is logout then you don't go back...
14
by: j0rdanf1 | last post by:
Hi I have been asked to create a simple login form for a website and due to the lack of knowledge im struggling, so far I have a form which posts the information to the check.asp section <%...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.