It seems that Gollum does not actually enter Lothlórien - as you note the elves guarded its borders very well.
Gollum picked up the fellowship's trail in Moria, and followed them to the border of Lothlórien, marked by the Silverlode river. On January the 15th, the night before the fellowship entered Lothlórien he attempted to approach Frodo by climbing the tree where he was resting, but Haldir scared him away:
Something was now climbing slowly, and its breath came like a soft
hissing through closed teeth. Then coming up, close to the stem, Frodo
saw two pale eyes. They stopped and gazed upward unwinking. Suddenly
they turned away, and a shadowy figure slipped round the trunk of the
tree and vanished.
Immediately afterwards Haldir came climbing swiftly up through the
branches. ‘There was something in this tree that I have never seen
before,’ he said. ‘It was not an orc. It fled as soon as I touched the
tree-stem. It seemed to be wary, and to have some skill in trees, or I
might have thought that it was one of you hobbits.
The next day the company crossed the river, were blindfolded, and were brought to Galadriel. Gollum does not follow them however. In The Fellowship of the Ring we lose track of him after the incident in the flet, until the Fellowship leave Lothlórien, and he starts to follow them again on February the 16th as they go down the Anduin in boats. What was he doing during that month?
According to the time-scheme given in The Lord of the Rings: A Reader's Companion by Hammond and Scull, Gollum was waiting outside Lothlórien, but was captured by Uglúk, and under torture revealed that hobbits from the Shire were among the party that had escaped into Lothlórien. Gollum then managed to escape, and continued prowling the woods until he saw the departure of the fellowship.
This information is derived from the timeline scheme that Tolkien prepared (archived as Marquette MSS 4/2/18). Thanks to commenter David Roberts, we can confirm this information from The Chronology of The Lord of the Rings itself, which has now been published in the Vol 19 supplement of Tolkien Studies (edited by William Cloud Hicklin). The sequence of events is:
January 15 S[unday] | Gollum dogs the Co[mpan]y and climbs up flet.
Then escapes and haunts west-borders of Lórien.
17 Tu. | For many days Gollum lurks near Lórien, moving slowly towards
the southern borders.
24 Tu. | Gollum captured by Uglúk, but escapes after revealing that
Hobbits of Shire were with Gandalf, and enough is said to make Uglúk
certain that Ring was with the Company.
February 16 W. | Observes departure of Company and follows them.