#!/usr/bin/php [,name] Comma separated list of value names -[name] value to store corresponding the name Examples: $ startsession.php --names foo -foo "My foo value" $ startsession.php --names town,postcode,state -town "Kangaroo Point" -postcode 4169 EOT; exit( 0 ); } $knownNames = array(); $index = array_search( '--names', $_SERVER['argv'] ); if( false === $index ) { echo "too few arguments...\n"; exit( 1 ); } ++$index; if( !isset( $_SERVER['argv'][$index] ) ) { echo "too few arguments...\n"; exit( 1 ); } $knownNames = explode( ',', $_SERVER['argv'][$index] ); foreach( $knownNames as $key ) { // store something in the session $index = array_search( '-' . $key, $_SERVER['argv'] ); if( false !== $index ) { ++$index; if( !isset( $_SERVER['argv'][$index] ) ) { echo "too few arguments...\n"; exit( 1 ); } else { $sess->set( $key, $_SERVER['argv'][$index] ); } } // load values again... $value = 'unknown'; if( $sess->has( $key ) ) { $value = $sess->get( $key ); } echo $key . ": " . $value . "\n"; } echo "\nall done...\n"; exit( 0 ); ?>