$ix = count($_SESSION['ems_id']);
A small side remark.
What to you wish to use the $ix for?
If you are going to use it to assign values to the next index in the array, this would be wrong. Arrays starts at 0, but count will return the number of indexes including the first at 0.
If you have an array with 2 indexes, they will be placed at 0 and 1. Count() will return 2, and your $ix will contain 4 instead of 3 which is the next index, because you assign $ix with +1.