1

I want to set some data may be in the cookies when visitor first load the website URL. The url can be any. It can be a category page, product page etc. Is there any event so that I can set that data in cookie?

Can I use controller_front_init_before event?

2
  • 1
    you can set cookie using javascript onload function.Just put this script in header.phtml
    – Keyur Shah
    Commented Nov 27, 2013 at 7:54
  • @keyur. it may involve some php code also. SO I need an event Commented Nov 27, 2013 at 8:21

1 Answer 1

2

To my understanding controller_front_init_before is not the best way for setting a cookie as you can miss some redirects and also you have a minimal data in your disposal.

I would recommend using controller_front_send_response_before as the last event triggered before output is sent to browser.

2
  • Thanks Tom. It worked. But I want to perform some php action also. With this event the action is performed after the page load completely. That I do not want as I want to submit form action before page gets load. Commented Nov 27, 2013 at 9:44
  • Then you have to be more concrete in your question. Commented Nov 27, 2013 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.