I'm having some problems getting cookies through requests. After logging in, the function returned me a result of 200 and then when I retrieved the cookie it returned null again. How to fix that?
import requests
conti = requests.session()
cookies = {
'GuestData': 'UserID=-1158954818',
'_gcl_au': '1.1.1495151070.1703683523',
'__utmz': '200924205.1708611965.63.9.utmcsr=create.roblox.com|utmccn=(referral)|utmcmd=referral|utmcct=/',
'RBXSource': 'rbx_acquisition_time=3/3/2024 7:52:00 AM&rbx_acquisition_referrer=&rbx_medium=Direct&rbx_source=&rbx_campaign=&rbx_adgroup=&rbx_keyword=&rbx_matchtype=&rbx_send_info=1',
'_gid': 'GA1.2.2064840281.1709547997',
'__utmc': '200924205',
'_ga': 'GA1.1.1995917453.1706018446',
'_ga_BK4ZY0C59K': 'GS1.1.1709615277.29.0.1709615277.0.0.0',
'rbx-ip2': '',
'__utma': '200924205.861218028.1704026159.1709640430.1709644088.77',
'__utmb': '200924205.0.10.1709644088',
'RBXEventTrackerV2': 'CreateDate=3/5/2024 7:08:40 AM&rbxid=5627443362&browserid=213124497596',
}
headers = {
'authority': 'auth.roblox.com',
'accept': 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9,vi;q=0.8',
'content-type': 'application/json;charset=UTF-8',
# 'cookie': 'GuestData=UserID=-1158954818; _gcl_au=1.1.1495151070.1703683523; __utmz=200924205.1708611965.63.9.utmcsr=create.roblox.com|utmccn=(referral)|utmcmd=referral|utmcct=/; RBXSource=rbx_acquisition_time=3/3/2024 7:52:00 AM&rbx_acquisition_referrer=&rbx_medium=Direct&rbx_source=&rbx_campaign=&rbx_adgroup=&rbx_keyword=&rbx_matchtype=&rbx_send_info=1; _gid=GA1.2.2064840281.1709547997; __utmc=200924205; _ga=GA1.1.1995917453.1706018446; _ga_BK4ZY0C59K=GS1.1.1709615277.29.0.1709615277.0.0.0; rbx-ip2=; __utma=200924205.861218028.1704026159.1709640430.1709644088.77; __utmb=200924205.0.10.1709644088; RBXEventTrackerV2=CreateDate=3/5/2024 7:08:40 AM&rbxid=5627443362&browserid=213124497596',
'origin': 'https://www.roblox.com',
'referer': 'https://www.roblox.com/',
'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
'x-csrf-token': 'x8NFQh6DhTxD',
}
json_data = {
'ctype': 'Username',
'cvalue': 'YOURACCOUNT',
'password': 'YOURPASSWORD',
'secureAuthenticationIntent': {
'clientPublicKey': 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9UZpDu3aF0zEtSBBypO/fl8TN+lyQGN3NQA4uQPg7tXklMEfim2cfVxnIG6BthEY3cAz6LFEa2egQ7bxYYrirw==',
'clientEpochTimestamp': 1709644482,
'serverNonce': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IkZXVzlGNFFWSDJIQlc5R0siLCJuYmYiOjE3MDk2NDQ0ODIsImV4cCI6MTcwOTY0NDc4MiwiaWF0IjoxNzA5NjQ0NDgyLCJpc3MiOiJoYmEtc2VydmljZSJ9.0Xiso57zVi8NJ6oGgZEcd_4cTBXRiUjC1yWry6qrHf4',
'saiSignature': 'IlXYOP97iWI7qdIx9pxLKSaasP+JWl1YrKYof1ibvYz3/A3L3oNqUx9oNLH5cl09+KyvX11V+3hYDUucY/od+A==',
},
}
response = conti.post('https://auth.roblox.com/v2/login', cookies=cookies, headers=headers, json=json_data)
main_web = conti.get("https://www.roblox.com/home")
cookies1 = main_web.cookies
cookies2 = response.cookies
print(cookies2, cookies1)
The results I want
{'domain': '.roblox.com', 'expiry': str, 'httpOnly': value, 'name': '', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': ''}
but it print
<RequestsCookieJar[]>