Forums

Set a cookie on submit button?

Shriek 30 Oct, 2009
Hi
I know almost zero about cookies but i managed to use MetaMod on my Chronoforms page to set a cookie and redirect to a different page if it is found already. The idea is they fill out the form and are redirected to the new page afterward, but if they have already filled out the form they go straight to the new page. Only problem is that if they just refresh the page the cookie is set and they go to the new page without filling out the form anyway. So, my question is, Is it possible to set a cookie on submit? And if so, how? In dummy terms please and thankyou.
Andrew
Shriek 30 Oct, 2009
I fixed the refresh prob by making another instance of metamod on the page it is redirecting to and having the set cookie line on there and nothing else and deleting it off the form page. That way refreshing the form doesn't matter.
GreyHead 30 Oct, 2009
Hi Andrew,

It's entirely possible to set a cookie on submit:
<?php
$session =& JFactory::getSession();
$session->set('cookie_name', 'cookie_value');
?>

See Joomla docs here

Bob
Shriek 30 Oct, 2009
Thanks for that Bob.
Appreciate your help.
Andrew
This topic is locked and no more replies can be posted.