0

Is there a service method I can use to get (any kind of) session data by giving the cookies CraftSessionId as a parameter?

if would look something like this. craft()->userSession->getSessionBySessionId($craftSessionId)

Rbijker.com
  • 252
  • 2
  • 9
  • What are you trying to accomplish? Are you thinking there would be multiple PHP sessions for a user? Or are you just looking to see how to read from and write to session? – Brad Bell Mar 17 '16 at 22:29
  • Im using the ElementAPI (https://github.com/pixelandtonic/) . I see that you wrote it. Great :-). – Rbijker.com Mar 17 '16 at 22:45
  • So with this plugin I want to make a json API for Android and IOS apps. I want to create API urls to log the user in and authenticate the user. – Rbijker.com Mar 17 '16 at 23:00
  • I wanted to use craft()->userSession methods for this in the API but since this uses php SESSION I thought that it will only work when you visit the page with a browser, not when making calls from Android and IOS apps. eg. craft()->userSession->isLoggedIn I dont think will work in this case (am I correct?). So I want to make a API url that can log the user in, and give some kind of a session id in the response. Then the device can make other api calls and include this session id so that I can authenticate each call the user makes. Is this the way to go about it? Do you have any suggestions? – Rbijker.com Mar 17 '16 at 23:06
  • @SiteHopper I'm attempting to do exactly the same thing - I'm using the ElementAPI for a client side app and would like to authenticate api calls. Did you find a solution? – Adam Soffer Jul 27 '16 at 00:35

1 Answers1

1

I don't think I'd use PHP's session for this at all, but recently posted some thoughts on a similar question here https://craftcms.stackexchange.com/a/14188/57 about using custom tokens or authorization headers to perform the authorization.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143