Magento Cookies not Working in Chrome or Opera on Frontend

So, I was testing the “this site is using cookies” functionality in Magento. It worked fine on a local environment but failed to work on a test “live” IP address site. I say failed, but it worked fine in IE and Firefox whereas in Chrome hitting the “I agree to cookies” button didn’t set a cookie and redirected. I eventually solved it. Continue reading Magento Cookies not Working in Chrome or Opera on Frontend

Magento: Passing a value from a controller into the phtml

Another Magento quickie for when you want to pass a value into your phtml template file that is set/generated inside the controller.

Inside the controller you can do this:

$block->assign(array(“myVarName”=>”value”));

Where $block could be something like

$block = $this->getLayout()->getBlock(“head”) ;

if you wanted to pass the value into the head template.

You can also set a value like this:

$block->setData(“myVarName”,”value”)

Then, inside the phtml template file you can get the value like this

$this->myVarName

Note you can pass multiple variables through a single $block->assign() like this

$block->assign(array(
“myVarName”=>”value”,
“anotherVar”=>123,
“enoughVars”=>true
));

Saving the page HTML in Chrome without reloading

This chestnut can drive developer crazy.  In Google Chrome hitting “save as” or “view source” will reload the page.  On pages where sessions or cookies are cleared (shop checkouts for example), form data is submitted, or the like, then the reloaded source may no-longer be the same as the page you were just looking at.  Argh. Here is my solution to the issue. Continue reading Saving the page HTML in Chrome without reloading