API
Version 7.x > API > Polls: Check if voted without cookie (PollInfoProvider.SetVoted) View modes: 
User avatar
Member
Member
@davey_lad - 11/29/2012 10:40:15 AM
   
Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Hi,

I was wondering if there were any other ways to mark a poll as voted by a user without relying on a cookie and have it persist across different machines/browsers/sessions ?

As far as I can tell Kentico out of the box relies entirely on the "CMSVotedPolls" cookie to determine whether any given user has voted. Needless to say this is very easy to circumvent and the user can submit multiple votes easily if they delete the cookie, or use a different browser or machine etc.

The obvious solution would be to store there vote in the database.. is this possible or are we talking about custom code ?

If custom code.. any suggestions ?

Cheers
Dave

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/30/2012 1:42:06 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Hi,

Yes, you need to store the value somewhere else than in browser or session. So, in the database. You will need to add a custom logic that wills ave the voted value together with the user ID. However, I ado not know how big is your site, but this can have pretty big impact on the performance in case of high traffic site and multiple users voting at the same time - checking each one separately and getting and saving the data to the DB.

Best regards,
Juraj Ondrus

User avatar
Member
Member
@davey_lad - 11/30/2012 2:16:19 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Thanks for the reply. As I suspected then.. custom code.

The site is an intranet portal targeting around 3000 users (not concurrent).

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/3/2012 2:03:40 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Hi,

So, the load should not be that big. However, you need to create e.g. a DB table to store the user information about which user voted and which not.

Best regards,
Juraj Ondrus

User avatar
Member
Member
@davey_lad - 12/3/2012 2:50:42 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Have you thought of adding this option as a core feature ? i.e. in a similar way you can choose to store images on disk or in db.

It would be quite useful for I think.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/3/2012 2:59:36 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Hi,
It would be hard to create something general that won't affect the site performance that much and so on.

Anyway, I was just thinking - why don't you use the forms module to create the polls. The values are already stored in the DB and you can have a hidden field that will record the user id and then you can filter out duplicate votes.

Best regards,
Juraj Ondrus

User avatar
Member
Member
@davey_lad - 12/3/2012 4:51:59 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
But isn't that statement also true for whether you choose to store files (images etc) in the DB or on Disk, or both?

Your choice is potentially always going to have an effect on performance one way or the other. But there is a choice.. it's up to the developer to gauge what the correct choice is in the end.

I think, as it stands, regardless of whether I look at using Forms or Polls some amount of custom development is going to be required.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/3/2012 5:08:42 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
Hi,

If you have a file - you have some GUID - so you are going directly for that particular file. In your case, each time a poll is submitted, you will have to compare all previous answers from that poll (and also distinguish the polls) - som in general you can have from tens records in the polls to tens of thousands answers. So, event the SQL query might be simple, getting the data and working with them might be more complicated. It sounds easy - but creating something general that could be used on a high traffic web site is not that easy.

Best regards,
Juraj Ondrus

User avatar
Member
Member
@davey_lad - 12/3/2012 4:55:54 AM
   
RE:Polls: Check if voted without cookie (PollInfoProvider.SetVoted)
On another note.. using Forms to create "Polls", when there is already are Polls module is essentially at odds with what we're trying to achieve.. and thats an intuitive, easy to use platform for our client.

The phrase "square pegs in round holes" springs to mind.