Extracting (unzip) with PHP ZipArchive::open

The default command (without flag) to open ZIP archives seems not to work in PHP in some cases. Try to use the following code instead.

<?php
$zipFile = "./anyfolder/filename.zip"; // Local Zip File Path
$zip = new ZipArchive;
if ($zip->open($zipFile, ZIPARCHIVE::CREATE) === TRUE ) {
    $zip->extractTo('./anyfolder');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>

Make sure that you have the required read/write permissions.

PHP sessions in wordpress

Add this to you functions.php

add_action('init', 'myStartSession', 1); //Initialize session
add_action('wp_logout', 'myEndSession'); //End session on logout
add_action('wp_login', 'myEndSession'); //End session on account change

function myStartSession() {
   if(!session_id()) {
      session_start();
   }
}

function myEndSession() {
   session_destroy ();
}

Access the value in normal PHP fashion

$_SESSION['myKey'] = "Some data I need later";

Source: https://silvermapleweb.com/using-the-php-session-in-wordpress/

ERR_CACHE_MISS & PHP

Most likely the error ERR_CACHE_MISS has do do with PHP sessions. To get rid of it add few lines of code before your session start.

header('Cache-Control: no cache'); //no cache
session_cache_limiter('private_no_expire'); // works
//session_cache_limiter('public'); // works too
session_start();

Source: Stackoverflow

Back to Top