Hi, all.

I have a login form with a checkbox that needs to create cookies if checked. How is it possible to check after the form has been submitted if the checkbox has been checked?

I have the following code in 'application/forms/Login.php':

$remember = new Zend_Form_Element_Checkbox("remember", array('disableLoadDefaultDecorators' => true, 'required' => false));
$remember->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => 'span'))))->setDescription("Remember me");

And in 'application/controllers/Auth.php':

$form = new Application_Form_Login();
$request = $this->getRequest();
if($request->isPost() && $request->getPost('submit_login')) {
    if($form->isValid($request->getPost())) {
        if ($this->_process($form->getValues())) {
            $data = $form->getValues();
                setcookie("username", $data['username'], time()+60*60*24*100, "/");
                setcookie("password", $data['password'], time()+60*60*24*100, "/");

The code works fine, but it creates cookis, no matter if checked or unchecked. Please advise. Thank you.

Recommended Answers

check the value of

Jump to Post

All 2 Replies

check the value of


Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.