0

I am writing a module that allows users to put comment on each paragraph. So in my module I have added a new field to comment table called "paragraph_id" and I have also added a new field to comment form that say:

 Which paragraph do you want to put comment on?

After each paragraph I have added a link saying:

  Put comment on paragraph 1 (2,3, ...., the number changed based on the number of the paragraph.

in order to this, I have written the following in node.tpl.php:

        for ($i=1;$i<$number;$i++) {

        print render($paragraphs[$i]);
       ?>

      <a href="#commenting">Put comment for Paragraph <?php echo $i?><br></a>


    <?php

I want to do one the following options:

1) Eliminate the new field which asks for the number of the paragraph from comment form, and do something that when a user for example clicks on a link like:

   Put comment on paragraph 1

, the number "1" automatically got save in comment table in "paragraph_id" field.

2) Or keep the field that asks for paragraph number in comment form and when user clicks on a link like

 Put Comment on Paragraph 1

while he is getting directed to the comment form, the value of that field (paragraph_number in comment form) sets to 1.

How can I do it?

1
  • 2
    What do cookies have to do with what you want to do? Aside from the question title there is no other reference to cookies in your question.
    – rooby
    Nov 16, 2014 at 2:57

2 Answers 2

0

Drupal automatically ensures that a user has a session, so your script can simply read and write to the $_SESSION superglobal array.

0

To set the expiration value for your website's session cookies: Go to Configuration > Session expiration.

Select from the following expiration options:

  1. Default (3 weeks 2 days) - Removes the session cookie from the user's computer 3 weeks and 2 days after creation.
  2. When the browser session is closed - Removes the session cookie from the user's computer when the user closes their browser.
  3. After a specific period of time - Removes the session cookie from the user's computer after an elapsed time period. Enter a time value that's based on your selected date unit (such as minutes or weeks).

Click Save configuration.

Not the answer you're looking for? Browse other questions tagged or ask your own question.