It seems like it would be quite hard to tell the difference between a muggle born witch/wizard and a normal muggle just passing by, they seem to be virtually the same except for the witch/wizards potential or capability to perform magic.
As is explained in some detail in Can a Muggle get through to Platform 9 & 3/4?, Harry Potter and the Deathly Hallows specifically depicts the family Evans on platform 9¾, three of whom were muggles. So either the barrier recognizes the families of muggleborns, or the barrier does not block muggles at all.
Since we also know that there are plainclothes Ministry of Magic employees on-site to do memory charms anyway, the latter seems far more plausible than the former. If anyone tries to lean on or otherwise passes through the barrier improperly, they can memory charm the muggle and send them on their way. This is presumably much simpler than trying to come up with a set of wards that precisely blocks only those muggles who are not "supposed to" go through.
Muggles can pass through the barrier
As explained by Kevin, there are examples of Muggles being able to access platform 9 and 3/4. (for example, Lily's family as seen in Snape's memories). This conveniently allows muggle parents to go with their children.
It is suggested that one cannot pass inadvertently through the barrier
When Harry asks Mrs Weasley how to get on the platform, she answers :
'Not to worry', she said. 'All you have to do is walk straight at the barrier between platforms nine and ten. Don't stop and don't be scared you'll crash into it, that's very important. Best do it at a bit of a run if you're nervous.'
Why does Mrs Weasley insist so much on not stopping and not being afraid? My guess is, just as in many magical deeds, one has to be focused and confident for it to work properly. Maybe you have to know and believe that you can pass through the barrier. This would explain why someone just leaning on the barrier on accidentally bumping into it cannot pass through it. Well-informed Muggles could do it just as any Wizard or Witch.
We already know that magic can distinguish between Muggles and Muggleborns, e.g., the Muggle-Repelling Charm from Goblet of Fire:
Muggle-Repelling Charms on every inch of it. Every time Muggles have got anywhere near here all year, they've suddenly remembered urgent appointments and had to dash away again.
The simplest explanation of this is that it is possible for magic to detect whether or not a person is capable of performing magic. In fact, we know that to be the case from secondary canon, see Book of Admittance on the Wiki:
The Book of Admittance was a large, parchment book bound in black dragon hide at Hogwarts School of Witchcraft and Wizardry, in which the Quill of Acceptance wrote down the birth of every magical child.
The most likely answer is that the Hogwarts barrier lets through anyone who is on the Book of Admittance, as well as their parents or guardians.
... whether that's done automatically, or whether there is a list somewhere saying who is allowed through the barrier which someone writes from hand based on the Book of Admittance, canon does not say. There would have to be some way of making exceptions, but possibly the magic just isn't strong enough to keep out an adult witch or wizard, or there's a clause along the lines of "anyone accompanied by a Ministry employee".
There are plenty of other possibilities as well, the most obvious being that the barrier simply lets in anyone with magic as well as anyone who is with them. Keep in mind that, in the Harry Potter universe, magic is perfectly capable of following that sort of slightly vague rule; it isn't at all like, say, programming a computer where you have to provide detailed and explicit instructions. And yes, the tickets might (or might not) play a part in this.
Kevin's answer is also plausible, though it would be somewhat risky; the Ministry watchers might mistake a Muggle for a Muggleborn, or overlook someone in the crowd. On the other hand, nobody has ever accused the magical community of being overly cautious. :-)