Tuesday, July 20, 2010

Check session expiration in php

/* The below script will check for users inactivity on page, If use open one page, then store the current time on $_SESSION['start'] variable. If he doesn't move cursor or click any key from keyboard for some time, and then if he click on any link it will check his inactive time. if it is greater than the limited time we set here 5 minutes as exmple, then he will redirected to inactive.php page */
?>
session_start(); // NEVER FORGET TO START
$inactive = 300; //means expire within 5 minutes
if(isset($_SESSION['start']) ) { // if session start set
$session_life = time() - $_SESSION['start'];
if($session_life > $inactive){ //if session time expired
header("Location: inactive.php"); //session expired message page
}
}
$_SESSION['start']=time(); //in pageload current time stored in session.
?>

Recommended discussions forums for php

http://www.w3schools.com/
http://www.phpfreaks.com/forums/
http://forums.digitalpoint.com/forumdisplay.php?f=37
http://forums.devshed.com/php-development-5/
http://phpbuilder.com/board/
http://www.phpfreaks.com/forums/
http://www.weberforums.com/
http://www.phpbb.com/community/viewforum.php?f=1
http://www.sitepoint.com/forums/forumdisplay.php?forumid=34
http://phpdebutant.com/
http://www.phpfreechat.net/forum/

Enable SSH access for you shared hosting account in godaddy server

To Enable SSH on Your Linux Shared Hosting Account
1. Log in to your Account Manager.
2. From the Products section, click Web Hosting.
3. Next to the hosting account you want to use, click Launch.
4. In the Settings section of the Hosting Control Center, click the SSH icon.
5. Type your Country Code, Phone Number, and Extension (if applicable) in the corresponding fields and click Enable.

NOTE: SSH requires a strong password. If prompted to change your password, click Change Password, type a new password, and click OK.
6. We call the phone number provided within 10 minutes. Once the connection is established, an automated message plays a message containing a PIN. Type the PIN number into the You will be called with your PIN field and click Verify.
Once verified, it may take 24-72 hours for SSH to be enabled for your account. During this time, you are locked out from the account as it is moved to a new server.

(QA) Testing, Staging and Production environments are now available with Heroku

Hi There,
Deploying application in multiple environements is a better approach for a successfull appliation. This is the default behaviour of the rails application to maintain deployment in development, testing and production environments. Development and testing versions are live on developer's local system and production environement lives on actual server.
Now heroku offers us to maintain the application with these three evnironments in live server withing heroku so that clients and your colleagues can provide feedback and suggestions on your application before pushing them to production.

Ex: If you want to deploy an application called "myapp" in Heroku. First create the production,staging and testing(QA) versions of the application, should use --remote option to override the defaults for the git repository names.

$ heroku create myapp-production --remote production
$ heroku create myapp-staging --remote staging
$ heroku create myapp-qa --remote qa

Now, if you want to deploy code to a particular environemt, do so by specifying the appropriate option
Ex:
$ git push staging master

and if you need to run db migrations use below

$ heroku rake db:migrate --remote staging
Finally, If you probably want to periodically copy your production data into your staging environment:

$ heroku db:pull --remote production

$ heroku db:push --remote staging

Now, when you want to deploy code to a particular environment, do so by specifying the appropriate remote:

$ git push staging master

And if you need to run migrations:

$ heroku rake db:migrate --remote staging

Finally, you will probably want to periodically copy your production data into your staging environment:

$ heroku db:pull --remote production

$ heroku db:push --remote staging

Note: Keep in mind that any environment variables you create or add-ons you add must be duplicated across environments for a consistent experience. For example, if you begin using memcache on your staging app, be sure to install it on your production app before you deploy your new code.

For more details
http://jqr.github.com/2009/04/25/deploying-multiple-environments-on-heroku.html
http://stackoverflow.com/questions/1279787/staging-instance-on-heroku