Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:32:11+00:00 2026-06-17T11:32:11+00:00

What method should I use to keep logged in my users, like google’s gmail?

  • 0

What method should I use to keep logged in my users, like google’s gmail? (You can stay logged in for almost an unlimited time if you want – stay logged in function – and even if your IP is changed mid-session, gmail still recognize you).

PHP Sessions last until the browser is closed (or 1440 sec), even with the use of session_set_cookie_parameters() I don’t know if it is a good practice or not. I would prefer using MySQL tables instead. One for user login attempts and one for sessions, but I wonder how should I accomplish this.

How can I identify users? The IP is no good, it can change and what if the user uses a proxy? All I want is to use a secure and convenient way.

Let’s put aside Network Eavesdropping and Cross-site Scripting, Im doing my best to counter these attacks. Brute force attacks would be denied with the use of login attempt logging and I use prepared statements to not get sql injected.

My other question is, how can I prevent session hijacking if I want an own login system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:32:12+00:00Added an answer on June 17, 2026 at 11:32 am

    I use a second specific cookie (ie not the session cookie), named ALWAYS

    • that cookie is set for a long life (eg a year)
    • its value is unique, determined in PHP based on UID and other random (time…) things, made from a hash key (choose your algorithm – md5 is said to be weak), eg “df67ewbhca9fasdi383hd.347234892.HASHFROMUIDSPECIFIC”
    • that value is stored in MySQL – user row – when the user logs in
    • the following algorithm is followed

      user_login() {
        if ( not signed in ) {
           if (cookies[ALWAYS] is present AND value is in DB AND not null) {
              log the user from that row , automatically
              create his session
           }
           else {
              regular_login()
           }
        }
      }
      
    • when the user logs out, delete the cookie ALWAYS, AND set that value to null in DB

    This way, the users who logged in previously, are (for a year, can be changed) automatically logged in when session expired, from the same browser they initially logged in.

    When a user logs out, remove the possibility of a cookie that has been stolen (…) by removing the value from the DB. Thus even though it could be stolen, it cannot be used anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What method should I use to keep items in a list if : I
I want to create a plugin called 'myPlugin'. Which method should I use and
I have a method that returns lot of data, should I use @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) for
In c# , when sending a parameter to a method, when should we use
How often should I use static methods generally? If I have like: Class1 _class34
How can I specify that a method should take as parameter a pointer to
this method keep returning 0. According to the developer docs this method should return
I heard that static methods should use only static variables in java. But, main
Which method should I override to be guaranteed to always get the correct size
What method should I follow in java to produce WordWord from Word#$#$% Word 1234

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.