title: Using same MySQL Connection in different PHP pages
body: <p>I am creating a simple Web Application in PHP for my college project. I am using the MySQL database.</p>
  
  <p>I connect to the database in login.php. After connection I assign the connection to $_SESSION["conn"] and then redirect to main.php.</p>
  
  <p>In main.php I write $conn = $_SESSION["conn"]. But the connection in $conn does not work.</p>
  
  <p>I thought that as the login.php script ends, the connection gets closed. So I tried using mysql_pconnect instead of mysql_connect but that too does not work.</p>
  
  <p>I know I can reconnect to the database in every PHP file. But I don't want to do this. I want to use the same connection in all PHP files.</p>