csckid Posted March 24, 2009 Share Posted March 24, 2009 setcookie ("TestCookie", "", time() - 3600); setcookie ("TestCookie", "", time() + 3600); What is the difference? Can we use session to use remember me tool on log in page? Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/ Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 the time you set is when the cookie expires. when that expired time is reached, the cookie on the system's computer is removed. time() - 3600 is in the past, so it basically deletes a cookie. time() + 3600 is one hour in the future...so the cookie you set with it will last for 1 hour you can use PHP SESSIONS to store information as the person navigates from page to page, but that SESSION only lasts until they close their browser. if you are looking for a "Remember Me" feature on a login page, you will need to use cookies Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792963 Share on other sites More sharing options...
KPH71 Posted March 24, 2009 Share Posted March 24, 2009 When you say session to use remember me tool, I assume that you mean making the session cookie last longer. You can do this using the function session_set_cookie_params. The only problem is that the session file on the server will expire after a set time. Therefore you can set other cookies containing and encrypted form of their username/userid and password. Or you can generate a string to be kept in a cookie that identifies them etc. Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792967 Share on other sites More sharing options...
revraz Posted March 24, 2009 Share Posted March 24, 2009 You can't use a session as a "Remember Me" tool, since your browser will pick up a new session id if you close it. Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792969 Share on other sites More sharing options...
csckid Posted March 24, 2009 Author Share Posted March 24, 2009 Sorry could't understand the part time() - 3600 is in the past, so it basically deletes a cookie. do we need session_id during coding? Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792979 Share on other sites More sharing options...
revraz Posted March 24, 2009 Share Posted March 24, 2009 You are confusing sessions and cookies. What is your question exactly? Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792981 Share on other sites More sharing options...
csckid Posted March 24, 2009 Author Share Posted March 24, 2009 I havent understand the part setcookie ("TestCookie", "", time() - 3600); i know that it deletes the cookie but why time() - 3600 is given? time() - 3600 is in the past, so it basically deletes a cookie. what does this mean? Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792991 Share on other sites More sharing options...
revraz Posted March 24, 2009 Share Posted March 24, 2009 It means since it's in the past to delete the cookie, not show how to explain that any better. Any negative value will do, it doesnt have to be -3600. Link to comment https://forums.phpfreaks.com/topic/150936-cookie-difference/#findComment-792998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.