RaythMistwalker Posted October 26, 2011 Share Posted October 26, 2011 Ok If anyone read my recent topics they will know I am making a forum system This system for users is currently about 1/3 complete and I now have a couple of issues. Firstly: When a user logs in I am using $_SESSION['RAYTH_MEMBER_ID'] to save their member ID for when they return. However every time the browser/page is closed it doesn't save and then they are logged out. How would I set it so it keeps them logged in until they personally logout? Secondly: Since It's a forum you expect there to be new lines and stuff when you Read posts in threads (like we do here). How would I set it when a user posts it replaces every return character from the input (enter/newline etc) and replace it with <br> in the mysql database? Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/249855-couple-of-things/ Share on other sites More sharing options...
AbraCadaver Posted October 26, 2011 Share Posted October 26, 2011 1. Read some of the notes for session_set_cookie_params 2. nl2br Quote Link to comment https://forums.phpfreaks.com/topic/249855-couple-of-things/#findComment-1282447 Share on other sites More sharing options...
PFMaBiSmAd Posted October 26, 2011 Share Posted October 26, 2011 1) The $_SESSION variables are designed to last just one browser session. To remember a visitor between visits to your site, you would typically generate a unique id (see: uniqid, which is essentially what a session id is), store this in a cookie and store it in your user table for that visitor. You would then be able to match that unique id with the correct record in the user table to get their actual user id. You should also store the logged in/logged out state in the user table so that if someone logs out, just supplying the unique id value won't allow someone to come to the site and appear to be logged in. They would actually need to supply the correct username/password to become logged in. 2) You would nl2br on the content when you display it (not when you store it.) Quote Link to comment https://forums.phpfreaks.com/topic/249855-couple-of-things/#findComment-1282448 Share on other sites More sharing options...
RaythMistwalker Posted October 26, 2011 Author Share Posted October 26, 2011 1) Ok so in the User Login table I add a new column called unique_id then write to that every time they log in and remove it when they log out? How would I store this in a cookie that will survive until manually deleted? 2) If a user hits the return button in a large text box will php remember that when storing it to the db and then i can use nl2br($TextFromDataBase) to retrieve it? Quote Link to comment https://forums.phpfreaks.com/topic/249855-couple-of-things/#findComment-1282449 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.