Magento and WordPress – Cookies on Both

This quickly covers being able to use Cookies outside of Magento that are set inside Magento.

I was working with another guy on a site that utilized both Magento and WordPress.  We kept the installs separate and just used the same styling on both to tie them together.  It worked nicely until we needed one bit of information in WordPress that we could not seemingly find a way to do.

I tried to do it with sessions but quickly ran into a directory tree problem because both directories were on the same level.

So I tried with cookies only to run into a similar problem.

I was finally able to get it working by making the cookie available across the domain with the following code:


setcookie("allebrum", $count, 0, "/", ".allebrum.com");

Then from WordPress I could call my cookie by using $_COOKIE[“allebrum”].

When setting the cookie the 4th parameter sets the cookie path to the root of the site, making it accessible outside the directory tree.

Advertisements

Simple Invoice, Gmail/Google Apps, SMTP and PHP

Using Gmail as an SMTP server can be a pain if you don’t know what you are looking for.  Fortunately, there are some decent tutorials online that can get you there….more or less.

I just wanted to recap my experience when trying to use Google Apps as my SMTP server when setting up Simple Invoice…..

1) Get the latest PHPMailer from http://phpmailer.worxware.com/.  Install accordingly.

2) Compile OpenSSL for PHP.  If on windows simply delete the semi-colon (;) in front of ;extension=php_openssl.dll in php.ini

3) When making calls to phpmailer, the host should be ssl://smtp.gmail.com, the port should 465, username should be your full email address and of course your password.   If the phpmailer version requires the input, SMPT_AUTH should be true.

That should be it.

For those using Simple Invoice, you can set your config.ini file to look like this:

email.host = ‘ssl://smtp.gmail.com’
email.smtp_auth = true
email.username =  test@gmail.com
email.password =  password
email.smtpport = 465
email.secure       =
email.ack     = true

Hope that helps someone.  If you have any questions, just comment and I’ll get back with you.