jwk811 Posted November 12, 2006 Share Posted November 12, 2006 i dont really know much about how to use cookies or how to make something like this on my site so i was wondering if someone could help me out on this.. an example would be terrific.. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/ Share on other sites More sharing options...
printf Posted November 12, 2006 Share Posted November 12, 2006 Is this a login system or do you just want to allow users the ability to remember page display aspects without the need to login? Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/#findComment-123550 Share on other sites More sharing options...
wildteen88 Posted November 12, 2006 Share Posted November 12, 2006 You can create a cookie with php using the [url=http://php.net/setcookie]setcookie[/url] functionHere is the basics of the function:setcookie(name, value, expirey_time);The name is the the name of your cookie, the value is what your cookie holds and the expire_time is when your cookie expires in seconds.So if you want to create a remember me cookie then you'd set it using this:[code]setcookie('remeberMe', $user_var, time()+3600*24*365[/code]What that will do is create a cookie called rememberMe which holds the value of the $user_var variable and it will expire a year from now. To access the cookie you'll use the $_COOKIE superglobal variable. Example:$_COOKIE['cookie_name_here']So to access your remeberMe cookie you'd use $_COOKIE['remeberMe']Note when you use the setcookie function make sure there is no output before you use this function, otherwise you may get a header already sent error message/blank screen. Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/#findComment-123552 Share on other sites More sharing options...
jwk811 Posted November 12, 2006 Author Share Posted November 12, 2006 so its actually pretty basic stuff? i was reading this tutorial and it seemed really complicated. [url=http://www.evolt.org/article/comment/17/60265/index.html]http://www.evolt.org/article/comment/17/60265/index.html[/url] Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/#findComment-123563 Share on other sites More sharing options...
wildteen88 Posted November 12, 2006 Share Posted November 12, 2006 There is more too it. However I have just shown you the basics. However you should follow that tutorial through though. Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/#findComment-123564 Share on other sites More sharing options...
jwk811 Posted November 12, 2006 Author Share Posted November 12, 2006 k thanks.. i already have a login system all set up i just need to add the remember me feature to it.. i have a good idea of how to do this now.. Quote Link to comment https://forums.phpfreaks.com/topic/27016-remember-user-with-cookies/#findComment-123567 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.