Reputation:
Update: I let-rally tried 12 suggested solutions but nothing worked at all. Is my question missing any details? The suggested answer doesn't solve the problem
In python I wrote:
print(s.cookies.get_dict())
where s is my session, the output is:
{'lubl': 'https%3A%2F%2Fopenworld.com%2Fconfirm', 'rishum': 'SHjshd2398-'}
Now my question is how can I edit rishum cookie such that I want to append 'test' next to it (or to make things simple replace it by 'test')?
For example, I want:
'rishum': 'SHjshd2398-test'
Note: as someone suggested I tried the following but didn't work:
print(s.cookies.get_dict())
s.cookies.get_dict()['rishum'] = 'test'
print(s.cookies.get_dict())
output before and after is:
{'lubl': 'confirm', 'rishum': 'SUqsadkjn239s8n-', 'PHPSESSID': 'nfdskjfn3k42342', 'authchallenge': 'asjkdnjnkj34'}
{'rishum': 'SUqsadkjn239s8n-', 'lubl': 'confirm', 'PHPSESSID': 'nfdskjfn3k42342', 'authchallenge': 'asjkdnjnkj34'}
Note the order has changed.
Upvotes: 0
Views: 448
Reputation: 21
In that case, you first need to delete your cookie and than create a new one, i would do it this way:
print(s.cookies.get_dict())
my_cookie = s.cookies.get_dict()['rishum'] + 'test'
s.cookies.set('rishum', None)
s.cookies.set('rishum', my_cookie)
print(s.cookies.get_dict())
Upvotes: 1
Reputation: 21
The way i understood from your question, s is json file that equals to
s = {'lubl': 'https%3A%2F%2Fopenworld.com%2Fconfirm', 'rishum': 'SHjshd2398-'}
than if you want to add 'test' to the end of 'rishum', you need to do the following
s['rishum'] = s['rishum'] + 'test'
and than
print(s)
I believe your mistake was that you called function twice, that's why you saw same answer.
Upvotes: 1