Of course, it is up to the employee to determine if they can handle their expenses on the salary granted to them. However, just as an employer may look at something like commuting time and say to themselves "wow, they're going to commute for 2 hours, that's going to be tough", an employer can look at someone who is older and assume more expenses and say "wow, they might be digging into savings, that's going to be tough".
Now, that should be just one factor of the hiring equation. And someone may be interested in transitioning fields, doing a startup, have a trust fund, live well below the normal standard of living, etc, etc, and may be ok with the salary.
But as an employer, hiring, you aren't just looking at what the employee is saying now, but trying to figure out if/when they'll be moving on (and picking someone who will be less likely to do so is just human nature--that's why job hoppers are looked down upon by some companies).
That said, how can you combat that? (I'm in my early 40s and am terrified of this.)
* start your own company
* consult
* don't job hop, settle into a company
* keep your skills up to date
* be productive enough to justify the extra money (be a true 'senior' developer)
* move into management, again, a higher leverage area.
I don't know, maybe there are other ways.