/    Sign up×
Community /Pin to ProfileBookmark

cookies displaying last login

hi,all

I have been wondering how can i use cookies to store and display last time the user has logged in to the system is this possible if so how will i go about it because i have no clue how to do any help will be great

Thank you.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@XeroSiSJun 19.2006 — I think the best thing for you to do is have a cookie showing that the user is online or not (with a simple 0 and 1) ... you must set a timestamp for example 10 minutes if the person has no activity within the 10 minutes the cookie turns to 0 but if he does the timestamp refreshes! ... also everytime the person goes to a page it should check to see if the cookie is 0 or 1, if it is 0 turn it to 1 and make put the current time on the lastlogin cookie!

Did you understand a thing I said?! .. neither did I ?
Copy linkTweet thisAlerts:
@shane_carrJun 19.2006 — Here, try this:

[code=php]
//put this at the very top of your php (inside the php tags of course)
$time = date('l, F j, Y at g:i:s a')
$y2k = mktime(11,59,59,12,31,2069);
setcookie('lastlogin', $time, $y2k);
[/code]


This makes a cookie with the last login time, in the format "Monday, January 1, 2006 at 9:30:15 am", in a cookie called "lastlogin" (that can be accessed easily with the variable $lastlogin) that will expire at 11:59:59 on December 31, 2069.

now, simply put

[code=php]
"Last Login: $lastlogin"
//where ever you want the login time
[/code]
Copy linkTweet thisAlerts:
@shane_carrJun 19.2006 — See [url=http://us3.php.net/date]this[/url] for more information about the date() function.
×

Success!

Help @william232 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...