clown[NOR] Posted April 7, 2007 Share Posted April 7, 2007 basicly what i've done is that I've made a CPanel on my personal website so I can log in and edit my site from there. But now I've made it as simple as I stay logged in for 1 hour.. after that I get logged out automaticly.. so what I wonder is what can I do to stay logged in untill I either close the whole site or I'm idle for moer than 5 minutes? Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/ Share on other sites More sharing options...
frosty1433 Posted April 7, 2007 Share Posted April 7, 2007 insert timestamp into database, and each time it is refreshed check if it has been 5 min, if yes update the timestamp, if no session_destroy... Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/#findComment-223444 Share on other sites More sharing options...
clown[NOR] Posted April 7, 2007 Author Share Posted April 7, 2007 but the issue I forgot to mention here, is that i'm not using database but textfile. and also, I've used cookies to store the login state.. if login state is equal to 1 i'm logged in, if it's 0 i'm logged out =) I'm a real rookie when it comes to PHP ... hehe... any good solutions that will work with the way I've made it now? Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/#findComment-223450 Share on other sites More sharing options...
frosty1433 Posted April 7, 2007 Share Posted April 7, 2007 storing the timestamp in the session should work just as well... Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/#findComment-223453 Share on other sites More sharing options...
clown[NOR] Posted April 7, 2007 Author Share Posted April 7, 2007 but how can I set up a session? see I've never worked with it. did some reading on php.net, but nothing more than that. can I add the session script into the allready exsisting login script that uses cookies? and 1 last question.. can u give me a guideline on how I can do it? this is the codes I've got in the login validation file: <?php $login_user = $_REQUEST['username']; $login_pass = $_REQUEST['password']; $login_string = $login_user . "@" . $login_pass; $login_array = file("filename.txt"); $login_match = false; foreach ($login_array as $login_ling) { if (rtrim($login_line) == $login_string) { $login_match = true; break; } } if($login_match){ setcookie("phps_loginstate", 1, time()+3600); setcookie("phps_loginuser", $login_user, time()+3600); Header("Location: http://www.nstclan.com/phpschool/v1.1/index.php?action=login"); } else { echo 'Incorrect username or password.'; } ?> i have to go to bed now, it's 9am here now and i havent slept at all, so i'll check back here when i wake up Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/#findComment-223463 Share on other sites More sharing options...
clown[NOR] Posted April 7, 2007 Author Share Posted April 7, 2007 hi again ppl! i wonder if anyone can answer my question in the post above? Regards, Clown Link to comment https://forums.phpfreaks.com/topic/45980-how-can-i-stay-logged-in/#findComment-223641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.