Jump to content

Couple of things...


RaythMistwalker

Recommended Posts

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

Link to comment
Share on other sites

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.)

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.