• V.J.

    Hey Maks,

    Thanks for this post. I was overthinking such a login system as well for an upcoming Phonegap app i’m going to make. It turns out to be a lot easier!

    What do you think about the Sentry package from Cartalyst? Would it be as easy to login somebody via this same approach?


  • Maks Surguy

    I am glad this helps! I was also doing the same mistake of overthinking this.

    Why do you need to use Sentry? What is the advantage of using it?

  • V.J

    I think the group and group permissions are a nice feature but i don’t know if i will eventually use it in the app..

  • Rahul Parekh

    Thanks for this. Helped a lot.

    Is there a way where I can do this for facebook login too?

  • Varun Nath

    I too had been over thinking this!.
    Thanks maks!

  • Hi, what if this form *was* on a separate domain, and what if each request was creating a separate session with Laravel? This is the problem I have… solving that is proving to be way harder.

  • Yeah for that you’d need a bit more ingenuity unfortunately… Have you checked out other tutorials online about this?

  • What about Laravel 4. It changes the rules.

  • Jaby

    having similar issue. I am able to log-in from a different domain (even local host) but the session will not persist across domains.

  • Please note that this will work on different domains. If you use Phonegap – it will work because Phonegap makes some exceptions about cross domain stuff and it could even store cookies across domains. Regular browser would not allow you to host a website at http://mysite.com and login/store cookies via ajax while being on http://myothersite.com. For that you would need to use much more complicated authentication mechanism, token-based authentication. The example given in this post is what’s called “session-based authentication” and it only works on the same domain or in PhoneGap.

  • Can you please elaborate on that a bit?

More in Code Blog
Building RESTful API in Laravel – part 3 – Integration with BackboneJS

For those of you who haven't been following this blog - I am posting a short series of tutorials that...