I need to retrieve the auto increment value and store it in the session after the insert query is performed. 

My table name is out where I have 4 fields id(primary key and auto increment), name, phone, email. 

```
$query = mysql_query($con, "insert into out(name, phone, email) values ('$name', '$phone', '$email')");                                                                            
$id = mysql_insert_id($con);                                                                               
while($rowval = mysql_fetch_array($query))
{ 
 $id= $rowval['id']; 
 }
if($query)
{ 
  $_SESSION['id'] = $id; 
}

```