0

i am building site in drupal 7, and i need script for read and write cookie with special functionality, which i want to put to block of selected content.

functionality: i have 2 contents and i need 2 cokies _ when view content -> write cookie -> read:if cookies of all 2contents are writed, user is redirected to other node.

Simple: 2 different cookies | read cookies - if all 2 cookies are writed, redirect.

i have tried some solutions, but didn't work for me :(

can somebody help me please?

i will be very thankfull

2
  • Do you need to use js? Or other way is fine as well? Commented Jan 23, 2012 at 15:48
  • I need to write record that user viewed that page, and when he view 2 contents, not allowing to view content in same day.For this reason i have chosen javascript cookie, but i am open to any ideas Commented Jan 23, 2012 at 18:32

1 Answer 1

1

Seeing as you want to prevent a user to accessing no more than 2 nodes/content in the same day I would suggest saving the ip address of the user and then checking against that in your server. (as cookies are easily deleted).

The way I would do it would be create a module which adds a table to the database with the ip address, date, content and any data you'll need to validate. Then I would check if there's 2 entries in the last 24 hours (and any additional requirements to view the content or validation) then prevent access if not, then add an entry to the database. Remember to implement hook_cron to keep your database clean (erasing entries older than 24 hours).

Sign up to request clarification or add additional context in comments.

1 Comment

you are right, i will create it with this type of solution, thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.