0

I am new to php programming. I designed a signup form for my site. After signup anyone can download some files in that site. Now I am looking for to set cookie for signup page.

<div class="field submit" style="text-align:center;">
  <input type="submit" value="signup"/>
  <?php 
    setcookie("signup",time()+3600, "/");
    if (isset($_COOKIE['signup'])) { 
      print "<p>Hello $_COOKIE[signup]</p>";         
    } else { 
      print "<p>Hello, This is your first visit</p>"; 
    } 
  ?> 
</div>

I am using the code like this but it was showing a warning.

Achrome
  • 7,773
  • 14
  • 36
  • 45
Sujitha
  • 115
  • 1
  • 1
  • 6

1 Answers1

1

You passing wrong parameter to setcookies, you missing second parameter value in it.

setcookie("signup","username",time()+3600, "/"); 

DEMO.

Rikesh
  • 26,156
  • 14
  • 79
  • 87