I am trying to store values of checkboxes in SESSION.

I have a list of options which is generated from the database values:

PHP Code:
PHP Code:
=mysql_query("SELECT * FROM table");
while (
$row=mysql_fetch_assoc($result)) {
input type="checkbox" name="checkbox[]" value="<?=$d_id?>><?=$d_name?></option>

when I submit the form (which includes this option list) If there was a mistake I want to return checked checkboxes (the ones that were checked before form submission).
If everything goes well then I want to put checkbox values into the database.. I guess using implode to comma separate them, but this is another story. I guess If I'll know how to do this with the Session values I'll be then able to get the values from database and pre check the checkboxes.

so can anyone help with the session thing? I need help with php code :\ i am a newbie...