Function to generate radom alphanumeric cookies I wrote this python function to generate random values to use as id for the cookies I have on my project.

These are some examples of what the return is:

'kck9874118vq{5470553602125615945684311372005'
'72195739g112py3472118v104h122z5038a100d118v912296336399110nu110n60041909'


That is the method:

def generateCookieID(userName):

    cookieId = ''
    for a in range(0,9):
        aux = randint(0,9999)
        if aux % 2==0:
            for i in range(1,4):
                letter = randint(97,123)
                if letter%2==1:
                    cookieId += chr(letter)
                else:
                    cookieId += str(letter)+chr(letter)
        cookieId += str(aux)   
    cookieJar['name'] = userName
    cookieJar['id'] = cookieId
    return cookieId


It works, but is it appropriate to use this way?
What could I do better?
If you are on python 3.6, you can just use the secrets module: which you should be using, in case the random value should be secret. 

From the documentation:

&gt;&gt;&gt; token_urlsafe(16)  
'Drmhze6EPcv0fN_81Bj-nA'


if you're below python 3.6, see here, how it's implemented. You  might just copy that.