hoopz Posted April 19, 2007 Share Posted April 19, 2007 I'm new to sessions and cookies. I'm trying to understand how to use them effectively. I've developed a login script. I used sessions to manage logins, but my server clears sessions after 24 minutes and I want users to be logged in for longer. So, I switched to Cookies. Now, users can stay logged in for as long as the cookie says. Now, when I read up on login scripts, it appears that most people use sessions (but I could be wrong). Is there a problem with ONLY using cookies? Should I be using both? Thanks, H Quote Link to comment https://forums.phpfreaks.com/topic/47784-sessions-andor-cookies-for-managing-logins/ Share on other sites More sharing options...
Ninjakreborn Posted April 19, 2007 Share Posted April 19, 2007 It shouldn't really matter. Sessions are more secure in nature than cookies, because the user can alter the cookies on there client system. However if you do it right you should be fine google "php cookies security" Get yourself up to date on the proper way to use them. Also google "Sessions vrs Cookies" to get an in-depth listing of good/bad affects of choosing cookies over sessions or sessions over cookies. Quote Link to comment https://forums.phpfreaks.com/topic/47784-sessions-andor-cookies-for-managing-logins/#findComment-233453 Share on other sites More sharing options...
MadTechie Posted April 19, 2007 Share Posted April 19, 2007 If you write the session after you read it, it will stay active until 24 of inactivity ie very basic <?php function SecChk() { session_start(); if($_session['sec'] = true) { $_session['sec'] = true; }else{ $_session['sec'] = false; die("please login"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47784-sessions-andor-cookies-for-managing-logins/#findComment-233575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.