How can you log out of iCloud if you forget the password? I recently bought an iPhone 6 from a friend, and there's still an iCloud user on the phone. How can I log out of iCloud if I have no clue what the password is? Keep in mind I have no clue what my password is to the email set on the phone either.
Since you bought it from a friend I would refer them to: What to do before selling or giving away your iPhone, iPad, or iPod touch and ask them to take these steps.

You should also familarise yourself with the above info.

In summary though, before selling any iDevice, you should:


Do a full backup of your device
Unpair your Apple Watch (if applicable)
Sign out of iCloud (if applicable)
Also delete the device from Find My iPhone (if applicable)
Sign out of iTunes and the App Store
Do a full Erase of contents and settings


It's fortunate for both you and your friend that you bought your iPhone from a friend.