Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change the session time

i need to add more time session life time . but cant add more 10-12 days

 /**
 * Logs in the user by saving user details and setting session
 *
 * @param username
 * @param fullName
 */
public void loginUser(String username, String fullName) {
    mEditor.putString(KEY_USERNAME, username);
    mEditor.putString(KEY_FULL_NAME, fullName);
    Date date = new Date();

    //Set user session for next 7 days
    long millis = date.getTime() + (30 * 24 * 60 *60 * 1000);
    mEditor.putLong(KEY_EXPIRES, millis);
    mEditor.commit();
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can use the actual value of the milliseconds you want. Convert from days to milliseconds for instance, in a clearer way.

long millis = date.getTime() + TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS);
//this will add 30 days

You can change the 30 to whatever days you’d prefer.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading