Skip to content Skip to sidebar Skip to footer

Js: How To Prevent Losing Session Per Refresh After Logging In In Soundcloud Api

I'm making a dashboard and pulling some info from the SoundCloud API. I'm relatively new to this API and I got as far as being able to pull the SoundCloud Widget per track listed.

Solution 1:

Have you concidered jStorage? Download it from here. Import the jStorage.js file to your code and you are good to go. <script src="YOUR_FOLDER/jStorage.js"></script> Then you can store the logged in user like this:

SC.connect(function() {
SC.get('/me', function(me) { 
    $.jStorage.set('userInfo',me); // store the user to storageconsole.log("Logged in userId: "+ me.id); 
    console.log('Logged in username: '+me.username);
    location.reload(); // reloads the page
    });

});

Then whenever you want to get info about the logged in user, just use:

var loggedInUser = $.jStorage.get('userInfo');

To sign out, just use

$.jStorage.deleteKey('userInfo'); // delete the logged in user
location.reload(); // reloads the page

Post a Comment for "Js: How To Prevent Losing Session Per Refresh After Logging In In Soundcloud Api"