Error message after clicking 'Preview' button in Templates (v. 2.9)

After previewing a different template, you receive a message that looks something like:

Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/storeadmin/includes/head.php:4) in /home/username/public_html/storeadmin/includes/open.php on line 158

This is happening because the system is trying to unset the preview cookie after headers are displayed.

  1. Remove this code from the open.php file in the /includes/ folder of the /storeadmin/ folder, around line 145:

    // REMOVE PREVIEW COOKIE IF NEEDED
    if (!empty($urlbase) AND $_SERVER['SERVER_NAME'] != "localhost")
    {
    if (substr($urlbase, 0, 4) == "www.")
    $cookie_base = substr($urlbase, 4);
    else
    $cookie_base = $urlbase;
    $thisurlbase = explode("/", $cookie_base);
    $ckdomurl = "." .str_replace ("www.", "", $thisurlbase[0]);
    }
    else
    $ckdomurl = "";
    if (isset($_COOKIE['previewtheme']) and $setpg != 'template')
    setcookie ("previewtheme", '', 0, "/", $ckdomurl, SB_SECURE_SITE);
  2. Open the head.php file in the /includes/ folder of the /storeadmin/ and replace the entire file's code with this code: