tags:

views:

29

answers:

3

My blog uses PHP and MySql.

I wanna give the user a feature to edit and delete their comments when they are in the site. They are not logged in users. In order to do that, how do I go about this?

They will not be able to edit or delete once they leave the site as session should expire.

A: 

See the documentation/examples for session_start()

AJ
I agree, once you start a PHP session you now have a unique session ID you can attach to the post and if the post's session ID matches the current user's, then display EDIT and DEL links.For security, make sure you only allow editing and deleting of data after X minutes because there will be ID overlap eventually and you don't want user Y being able to edit user Z's posts.
TravisO
@TravisO - good comment.
AJ
+1  A: 

The session will end when the user closes their browser or after a set period of inactivity on the site (typically 15 or 20 minutes). If you want the user to have more time to edit their comments I would use a cookie.

See setcookie() on how to create a cookie and $_COOKIE on how to read cookies.

macinjosh
A: 

you can store in session an array with the id's of the comment, i think they have an unique id.