Navi Gamage
Navi Gamage

Reputation: 2783

How to create a cookie on form submitting?

i have a light box form i want to create a cookie when user submitting that form...my cookie variables are setCookie("username",username,1000) i want to do this while user submitting the form...thanks..!

Your Full Name:

<p>Your Facebook Email Or Username: 
  <input type="text" name="email" value="" maxlength="60" size="60">
</p>

Upvotes: 2

Views: 3414

Answers (2)

Rukmi Patel
Rukmi Patel

Reputation: 2561

When you are submitting a form and redirecting it to your main page, at the top of that you can write code to set cookie ..

Upvotes: 1

daGrevis
daGrevis

Reputation: 21333

When lightbox is opened...

$('.lightbox').click( function() {

    $.post('save_cookie.php');

});

And save_cookie.php:

setcookie(...);

I did it with PHP because your only tag is php. You can do it with only javascript too.

P.S. I used jQuery here too.

Upvotes: 3

Related Questions