If you set your origin point of the stair rails to the bottom left corner, you can compare the Y position of the player (as well as overlapping the rails) and stairs rail to know when he should be in front or behind.
Basically if the player is overlapping the stair rails, but his Y position is the same as the stair rails or lower then he will be behind. If He is overlapping the rails and Y position is higher, then he will be in front.
~Sol