How can someone ask his fellow to stay in touch or add him on social networks? Is it allowed to ask this kind of questions on Stack Overflow.
You could put something in your profile for all to see. However, that would rely on the people you wanted to connect with viewing your profile.
Others have mentioned comments, but these are likely to be removed as noise.
A better way might be to find the person on chat and ask them in there.
Looking at the problem from the other end - you could check their profile to see if they've listed any social networks there (I have for example) and you could initiate the contact that way.