-marases
Assuming you're using the PDO code I posted.
To iterate over the results of the query, the variable $rowset would contain a multidimensional array.
In theory your query should only return 0 or 1 rows, and to ensure this it should probably have a LIMIT 1 added to the end of it.
$sql = "SELECT * FROM users WHERE usrNAME = :user AND usrPASS = :pass LIMIT 1";
With that being said, to iterate over the results its just a matter of:
if( count( $rowset ) == 1 ){
//We only have exactly 1 row returned.
$_SESSION['id'] = $row[0]['id'];
}
If you need to iterate over multiple rows:
if( count( $rowset ) ){
foreach( $rowset as $row ){
//Do something for each row
// echo $row['columnName'];
}
}
-evstevemd
While I think session hijacking/fixation is a concern in the grand scheme of things, the sql injection that was present in this example initially was far easier to exploit even at a novice level. Regardless a nice link with a very easy to follow explanation of the topic and a way to reduce the risk.