I could share an experience that didn't happen at a train station but at a bus station. This was in the autumn of 2006. I had walked the Camino de Santiago(Camino Frances), then took buses south and visited Fatima and Lisbon. From Lisbon took an afternoon bus to Madrid that would be arriving just after midnight. My plan was to stay the night at the bus station, buy a bus ticket to France to leave the next morning, hopefully put my backpack in a locker and waitout the few hours until daylight.
Arrived in Madrid; all good. At 1am they started to clear the bus station, saying that we had to wait outside.
Oh no. About 40-50 of us standing outside the main doors which would open at 6am. I noticed an English man from my bus(heard him speak) who was in his 40's. I'm then 51. Introduced myself and said that we could watch each others bags while we waited out the hours. He agreed.
Then looked around. There were a number of young men hanging around, no bags, no luggage, some without even a jacket. Why are they here? We went across the street to wait thought it was safer.
Morning came and it all worked out. At one point in the night 3 men came across the street to talk to us, ask us what we were doing, did we have cigarettes, ect....To this day i believe being alone would not of been good. I took a chance and picked a buddy. He had the same concerns as me.
I'm more wired-in today. At the very least I'd check Hostelworld. Get some addresses, check availability even if I didn't book. Check googlemap to have some idea of the lay of the land.