dimanche 3 mai 2015

Fetching cookies - Rails

I'm doing something related to cookies in webpage. However, I need to copy the cookie fresh from the page, instead of hardcoding it (I'm new to rails):

content = "blablablablablablablabla--blublublublublu"
unescaped_content = URI.unescape(content)
# retrieve the cookie live
data, digest = unescaped_content.split('--')
session_hash = Marshal.load(::Base64.decode64(data))

However, given the url, for example http://localhost:3000/login I want to be able to read the existing cookies for a specific user id. So let's say the session_hash has the following field:

session_hash['logged_in_id'] = 2

So I would like to be able to read all the cookies for that website related to that user id.

Note: Don't worry, I'm not hacking into anyones account, only testing some security settings.

Aucun commentaire:

Enregistrer un commentaire