How to check Login?

PHPAdamPHPAdam New
edited September 2014 in Vanilla 2.0 - 2.8

I have website on root; and forum on /talk/

jsConnectPHP is in place.

Yet no documentation?

I've set it up so to login; users are sent to forum. They login and are reffered back to the main website (great!).

Now im on the main website; how do I check the user is logged in? ...

I can see the session and cookie data is there; how to use it is the question?

All im realy trying to do is; use session or cookie data. Cross check it with database? I presume this is what JSCOnnect can do? ..

Comments

  • Welcome to the community!

    Are you looking to use Vanilla sessions as your site session?

    Or are you looking to start a Vanilla session with your site session?

  • PHPAdamPHPAdam New
    edited September 2014

    Thank you for the warm welcome.

    I am looking to use Vanilla sessions as my site session.

    Currently users are sent to forum logn page, via a link: mainsite.com/talk/entry/signin?Target=http://mainsite.com

    Therefore redirected back to main website. So looking to check user is logged in on the main website, via checking the sessions Vanilla forum set.

  • You can get the current user by doing an AJAX request for their profile via http://mainsite.com/talk/profile.json. This will return either the signed in user and their profile data, or an exception object.

    If your site is small or you are creating your web application yourself, I would suggest running your site inside of the Garden framework.

  • If you only need the UserID, you could use this:
    https://gist.github.com/lincolnwebs/700805

    $VanillaIdentity = new VanillaIdentity();
    $VanillaUserID = $VanillaIdentity->GetLoggedUserID();
    
  • PHPAdamPHPAdam New
    edited October 2014

    @hgtonight‌ I need it server side. I could not figure out a "safe/secure" way to use what you suggest with the users AJAX feeding back to mainsite. Could be easily fudged.... That being said; I am going to use it! (not for authentication) now you have brought it to my attention.

    I looked at the Garden Framework (im using codeigniter) but not much documentation and im reliant on the CodeIgniter Docs as it is.

    @Bleistivt I used a different one that was mentioned in the comments. Your link did not have GetLoggedUserID.

    I am using codeigniter - so a quick play around adding it as a Library, figuring out has to pass perimeters (name, salt, hashmethod) and it works!!!
    I thank you very much!

    You are both great; again thanks.

Sign In or Register to comment.