The E peg on my student violin kept slipping & would not hold tension unless it was pushed in extremely hard, and sometimes not even then. It was frightening because I don't like using such pressure on a delicate instrument like that. Anyway today I finally had enough & decided to try putting a speck of rosin on the peg. It had great grip straight away.
The only problem was I was so used to pushing the peg in hard to get it to grip & yet by doing that with the rosin added it gripped far too strongly.
So I tried only pushing the peg in gently & it gripped perfectly & the E string holds it's note perfectly.
Rosin would act as a glue & lock the peg inside if too much was used. I only tried it on this student violin because it is an extremely cheap violin & there wasn't much to lose if everything went wrong.
I'll frequently loosen the E peg & re-tension it to make sure the peg isn't becoming glued by the rosin.
When I put the rosin on the peg & inserted it into the box I turned the peg a few times to get the rosin to transfer onto the wood inside the peg hole, then I took the peg out & wiped the rosin completely off the peg. The reason I did this is because glues usually work better if both surfaces are coated & so I only wanted one surface coated with the rosin.
I suppose I should buy the correct solution for the job but I didn't want to wait that long. I'll get the proper solution for my expensive violin & cello if their pegs ever start slipping.
PS - Don't be afraid to push your peg in for fear of hurting your instrument. Just make sure your fine tuner is unscrewed to the point where it won't rattle and then use your peg so you don't break your string.
A lot of rosins have materials in them that are abrasive and could loosen the peg more in time. The problem with cheap violins is that you don't get the set up that you would get buying in person, a more expensive violin. The correct fix is to have the peg hole re-reamed and the peg turned. The tools are asy to use, but cost as much as a cheap violin. What you have done is fine for now. Some time in the future maybe you can get the peg holes reamed and if needed the pegs turned when you are getting new strings. Most will just buy some peg dope. It comes as a liquid or a thick paste like chap stick. Both work well. And are cheaper than having the violoin re-set up. Just add fine tuners if you don't have them. You should be able to get it in tune with just the fine tuners after the strings break in.