2

I am trying to establish a persistent session in MATLAB for the POST method.

For instance, in Python, the requests library allows the use of persistent sessions like so:

s = requests.session() 
s.post('localhost/login.py', login_data) #logged in! cookies saved for future requests.
r2 = s.post('localhost/profile_data.json')

How could this be done in MATLAB?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Please elaborate {much more}. What is happening now? What is the desired behavior? What did you try? Providing an example in a different language, where it works, may also be helpful. – Dev-iL Jun 16 '15 at 18:06
  • @Dev-iL for instance in python: s = requests.session() s.post('https://localhost/login.py', login_data) #logged in! cookies saved for future requests. r2 = s.post('https://localhost/profile_data.json') if i am using requests library of python. Here I guess I would urlread in MATLAB. – JosephAgnes Jun 16 '15 at 20:54
  • hi guys any comment and guidance? – JosephAgnes Jun 17 '15 at 00:23
  • I'm unfamiliar with `urlread`, and would myself recommend equivalent `Java` solutions (which you can call from MATLAB). Few examples / resources you might find useful: [link1](http://moleksandr.blogspot.co.il/2009/01/matlab-can-get-binary-data-and-set.html), [link2](https://www.mathworks.com/matlabcentral/newsreader/view_thread/78555#199543), [link3](http://undocumentedmatlab.com/blog/expanding-urlreads-capabilities), [link4](http://www.mathworks.com/help/matlab/call-python-libraries.html). – Dev-iL Jun 17 '15 at 07:30
  • @Daniel Roseman if you can comment. basically calling functions from other languages would be second option for me. I would right now try to find a solution solely in MATLAB. – JosephAgnes Jun 17 '15 at 09:06
  • You do realize that `urlread` uses `Java` internally, right? You could also try [link5](http://www.mathworks.com/matlabcentral/answers/29352-using-web-services-with-matlab-cookie-issue) and [link6](http://www.mathworks.com/help/matlab/ref/webread.html). – Dev-iL Jun 17 '15 at 09:24
  • yes I do realise indeed. I just want to maintain the session using urlread. – JosephAgnes Jun 17 '15 at 09:32
  • @Dev-iL Hi, I am still unable to do the task of maintaining persistent http session in MATLAB. I was wondering if I could use cookies manually to set and store the password to stay logged in. any comments about persistent cookies in MATLAB? – JosephAgnes Jun 24 '15 at 14:42
  • Like I said - I have no clue in these things, never tried anything like that myself; my only suggestion was to read about how this is done in Java and implement that solution in MATLAB. Good luck! – Dev-iL Jun 24 '15 at 14:50

0 Answers0