rating system and session

Hi everyone,

so I’m developing a rating system and I decided to use sessions stored in database to prevent users from multiple entries.

This is what I’ve got so far:




if(Yii::app()->session['line_'.$_GET['id']] !== $_GET['id'])

{

  ...

  if ($model->save() )

  {

    Yii::app()->session['line_'.$_GET['id']] = $model->id;

    ...



It works just fine but I’m not sure if it is a good solution as there will be dozens if not hundreds of items to rate and creating always new variable in session doesn’t seem right to me. Maybe storing them in an array would be better choice but I’m having trouble to make it work. I tried this:




if(Yii::app()->session['line']['id'] !== $_GET['id'])

...

Yii::app()->session['line']['id'] = $model->id;



but I’m getting this error: Indirect modification of overloaded element of CDbHttpSession has no effect

Any thoughts on which approach is better or how to make the one with array work?

i don’t think the session is a good place to store the vote history nether cookie . you 'd better create a vote_track table for tracking every vote :




// just a sample ,modify it depends your situation 

vote( vote_id ,user_id ,ar_class,ar_id, vote )



see here for detail Allowing only one vote per person on a voting system: