Archive for September, 2007

How page expires when pressing back on banking sites

Posted in PHP, Web Programming on September 28th, 2007 by Abbas Ali – 2 Comments

On many banking sites you will find that when back or refresh button is pressed the session expires and it shows you a custom page. Well below is a simple PHP code which will do the same. The code is very basic and illustrates just the logic.

Include the below given code in all your scripts.


// First make sure that the page is not cached
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

// Start the session
session_start();

// If there is a key in session and there is no key in GET then exit with error.
if (isset($_SESSION['key']) && !isset($_GET['key'])) {
  echo "SESSION expired";
  exit;
}

// If there is a key in GET then validate the key against the key stored in session
if (isset($_GET['key']) && isset($_SESSION['key'])) {
  // Compare the key passed with the one stored in session
  if ($_GET['key'] != $_SESSION['key']) {
    echo "SESSION expired";exit;
  }
}

// Generate a key for next page and store it in session.
$next_key = md5(time());
$_SESSION['key'] = $next_key;

// Now $next_key is the key which should be passed in all links
// Something like <a href="second_page.php?key=$next_key">Secon page</a>
// If no key is passed or invalid key is passed then session expire error will be shown

$next_key should be passed in the URL to all scripts.

  • Share/Bookmark

Upgraded to version 2.3

Posted in Miscellaneous on September 28th, 2007 by Abbas Ali – Be the first to comment

Today i upgraded this blog to wordpress version 2.3. I had a few difficulties in doing so but in the end i was able to do it.

Everybody – enjoy this wonderful open source application.

  • Share/Bookmark

Getting Married

Posted in Personal on September 26th, 2007 by Abbas Ali – Be the first to comment

Yes, you heard it right, i will be getting married on 14th Nov 2007. My would be wife’s name is Tasneem and she is from the wonderful city of Hyderabad.

We first met in my cousin’s wedding way back in Dec 2004. I am really excited and looking forward to spend the rest of my life with her. I will be busy for the next couple of months in preparations and other things.

  • Share/Bookmark

Mentoring in Google Summer of Code

Posted in Open Source on September 26th, 2007 by Abbas Ali – Be the first to comment

Its been very long since i wrote last time and yes i know it is too late to mention this (as GSoC is over) but i was damn busy with work and other things.

Anyways the news is that Coppermine Photo Gallery was one of the open source projects which participated in Google Summer of Code 2007 (GSoC). Four students were chosen to work on different aspects (enhancements) of cpg. I was mentoring one of the students, Sander Weyens. Being a mentor was a wonderful first time experience. I really liked the work done by Sander and other students. Thu Tu did a wonderful job in coordinating the whole program for coppermine. She is in the dev team and was also a mentor.

Google is organizing a mentor summit in Mountain View, California on 6th Oct-07 and Coppermine has been invited. Any three mentors from coppermine can attend the summit and Google will be giving $1200 as travel expenses (for non U.S mentors). I am being told by other Dev Team members (specially Thu) to attend the summit but because of work load and visa problems i cannot. Though i would have loved to go there and represent coppermine. Better luck next time ;) .

  • Share/Bookmark