I was working on a WordPress project which i need to clear the PHP session when the browser or browser tab is closed. Although Javascript provides the window.onbeforeunload event but it will be triggered even whenever you leave the website. Finally i got a simple solution from Daniel Melo in StackOverflow. The following code required jQuery and i have included the Google one in the HTML.
This is another example of implementing simple Ajax GET request. Please refer to Ajax – Simple Ajax POST Request for a POST request. Actually, both of them are quite similar and it is good to try both to get more familiar with the generic Ajax requests.
In PHP, we can use the header() function to redirect the URL.
In HTML, we can use the meta tag to redirect the URL.
For more information, visit PHP/HTML – Redirect URL in Seconds
Add the following code under the top PHP opening tag of wp-config.php.
<?php
if (!session_id()) {
session_start();
}
...
We can now make use of the $_SESSION[] in WordPress. The reason of putting the session_start() in wp-config.php is because this configuration file will not be overwritten during a WordPress update.
Updated @ 2012-08-02: Please note that their maybe security issue of using the PHP session. For more information, please refer to the following link. PHP $_SESSION variables
Actually configure Postfix or Sendmail for PHP mail() is the same. Both of them run the /usr/sbin/sendmail binary. It is quite confusing if we just look at the name of the binary but this is what Postfix did.
Whenever a rule is fired, you can add some conditions to validate if the actions should be run. And you can even setup a PHP code condition for rule. But this feature required the PHP Filter in the Drupal Core modules. Continue reading Drupal – Enable Custom PHP Code Condition for Rules→
If you find the fonts of your Drupal site quite boring. The @font-your-face module could make the text of your Drupal site more fun. Before proceeding, it would be great if your PHP is already enabled with the zip extension. but no worry if you doesn’t have the zip extension. We can still complete it without any problem.