TikTok sets cookies on the user's browser when the user interacts with the app, including when they view videos and other content, in order to enable certain features of its services such as video playback and personalization. The cookies are used to collect information about the user's preferences, interests, and interactions with the service, which is then used to tailor the user's experience and display targeted advertisements.