How to Destroy Session When users close the browser tab in php

We can use “onbeforeunload” javascript function 

include this javascript  code in your html named check_browser_tab_close.js

// JavaScript Document
* This javascript file checks for the brower/browser tab action.
* It is based on the file menstioned by Daniel Melo.
* Reference:     *
var validNavigation = false;

function endSession() {
// Browser or broswer tab is closed
// Do some your php function to destroy the session
alert("Your Session is destroy");

function wireUpEvents() {
* For a list of events that triggers onbeforeunload on IE
* check
window.onbeforeunload = function() {
if (!validNavigation) {

// Attach the event keypress to exclude the F5 refresh
$('document').bind('keypress', function(e) {
if (e.keyCode == 116){
validNavigation = true;

// Attach the event click for all links in the page
$("a").bind("click", function() {
validNavigation = true;

// Attach the event submit for all forms in the page
$("form").bind("submit", function() {
validNavigation = true;

// Attach the event click for all inputs in the page
$("input[type=submit]").bind("click", function() {
validNavigation = true;


// Wire up the events as soon as the DOM tree is ready
$(document).ready(function() {

And your HTML file looks like this 

<script type="text/javascript" src=""></script>
<script type="text/javascript" src="check_browser_tab_close.js"></script>
<h1>Hello Guest......</h1>
<a href="">My Portfolio</a>


About Heredoc :

Heredoc is a robust way to create string in PHP with more lines  without using quotations…

Heredoc in php start with <<< this operator



$string = <<<DEMO

This is a EXAMPLE

message with



echo $str



This is a EXAMPLE message with heredoc.



$name = “Guest”;

$string = <<<DEMO

Hello $name! <br/>

This is a

demo Example2

with heredoc.


echo $string;



Hello Guest!  This is a demo Example2 with heredoc.

Google+ Sharing Custom button for your app

Share Custom message from your own website using this

Step 1.

<?php $message=”Your Custom message goes Here……..”; ?>

Step 2.

<a href=”;?php $message  ?>” onclick=”‘;?php $message  ?>’,’gplusshare’,’width=450,height=300,left=’+(screen.availWidth/2-225)+’,top=’+(screen.availHeight/2-150)+”);return false;”><img src=”; alt=”Share on Google+” width=”55″ height=”22″ /></a>

thats it…..

Facebook Custom iFrame Share Button

Share anything on facebook  like link ,custom text – content, video ,image using this code from your website

Step .1

$title_face=urlencode(‘Title of Your Tab’);
$message=urlencode(‘Custom message ……………’);

Step .2

<a onClick=”‘;p%5Btitle%5D=&lt;?php echo $title_face;?>&amp;p[summary]=<?php echo $message;?>&amp;p[url]=<?php echo $url_link; ?>&amp;&p[images][0]=<?php echo $image_photo;?>’, ‘sharer’, ‘toolbar=0,status=0,width=548,height=325’);” target=”_parent” href=”javascript: void(0)”>

thats it ….ur share button is ready

Interview Questions For Joomla CMS

Joomla is Content Management System developed in PHP (open source)

Its uses MVC (Model-View-Controller) pattern


  1. Open Source
  2. Freely Available
  3. Developed in php
  4. MySQL Support which most popular database
  5. Admin And User Panel (Easy to Use)
  6. Released under the G|N|U General Public License 2 (GPL)
  7. Supports All International Languages
  8. Page Caching
  9. RSS Feeds
  10. Printable version of pages
  11. News Flashes
  12. blogs
  13. polls
  14. search
  15. Plugins (Third Party) Supports
  16. Modules Supports (to extend the functionality in Joomla)

What are pathways or breadcrumbs?
If you are on a particular page and to get to that page you had to go through several folders to find that particular page, then that series of links will be your pathway or breadcrumb. For example: Home >> Books >> Pages >> New Page.

How to remove the pathway or breadcrumbs?
If you want to remove your pathway permanently, you have to edit your html (index) file, which will normally look like this:
<div id=”pathway”>
<?php mosPathway(); ?>
</div>.      or you can search “pathway” word you can get it directly

What are section, categories and content items?

Sections and categories allow you to organize your content.

The basic structure is:
Sections => include Categories.
Categories => include content items.

  • Remove the page title from the front page 

    To remove the title from being displayed on the front page of your site, you need to change a parameter setting in the front page component.

    * First log into the administrative back end.
    * On the top menu click “Menu”->”mainmenu”
    * Click “Home”.
    * On the right side of the screen in the parameters section, locate the “Page Title” parameter       that is next to the radio buttons “Show” and “Hide”.
    * Click the “Hide” radio button.
    * Click the “Save” button to make your change permanent.