General Tips
Posted: Mon Feb 02, 2009 6:07 pm
Does anyone have any general PHP coding tips to share? Perhaps any little scripts/techniques they've written which constantly help when coding (especially debugging)?
Everyone uses sessions alot, and I find it's really annoying to reboot Apache everytime I screw up the $_SESSION array. So I've been using this for a while now:
Everyone uses sessions alot, and I find it's really annoying to reboot Apache everytime I screw up the $_SESSION array. So I've been using this for a while now:
Code: Select all
<?php
session_start();
if(isset($_GET['kill']))
session_unset();
else
{
$sessPath = ini_get('session.save_path');
$sessCookie = ini_get('session.cookie_path');
echo '<br>sessPath: ' . $sessPath;
echo '<br>sessCookie: ' . $sessCookie;
echo '<br>sessId: ' . session_id();
echo '<hr />';
echo '<br />current session array: '; print_r($_SESSION);
if(isset($_GET['one']))
$_SESSION['test1'] = 'hello1';
else
$_SESSION['test'] = 'hello';
echo '<br />session array after set: '; print_r($_SESSION);
}
?>
<br />
<a href="sessions.php">set test to hello</a><br />
<a href="sessions.php?one">set test1 to hello1</a><br />
<a href="sessions.php?kill">kill session</a>