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 3597118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:04:38+00:00 2026-05-18T20:04:38+00:00

I’m creating a login script for a website i’m developing, and am using PHP

  • 0

I’m creating a login script for a website i’m developing, and am using PHP sessions to authenticate users.

I’ve set the script to use HTTP only for the cookies, and to only use cookies for storing the session ID.

Basically, I’d like to know two things

1. Is there anything more I should do to make my login more secure?

and

2. The PHP Manual says that session_destroy() deletes the session data, but doesn’t unset any of the session variables. If this is the case, what is it actually destroying, and should I manually unset my session variables on logout?

Thanks for any help

EDIT:
I am using free hosting, and cannot install any Apache addons or change the php.ini file

EDIT:
I’ve read that using SSL is required to stop the session ID from being stolen, but I don’t have the ability to install OpenSSL on the server, so is there some other way I could protect the session ID?

  • 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-05-18T20:04:38+00:00Added an answer on May 18, 2026 at 8:04 pm

    The most important thing to remember:

    Don’t trust ANYTHING that comes back from the client

    Never assume that the information you are getting (in a form field (even hidden ones), session variables, etc.) are valid – use server-side logic to perform these checks.

    1.) Make sure your session is encrypted. If you are using PHP’s built-in sessions, the associated entropy (randomness) is relatively high, so you should be fine.

    2.) ONLY store the session id in the cookie. Any other information should simply be associated on the server using that id. I’ve seen many cases where the system engineer determines if someone is admin if the token ‘is_admin’ = true in the session. You can obviously see the problem with this.

    Some will complain that its an expensive operation, but I recommend creating a (my)SQL table for active sessions. Then, when the page is loaded, pull the associated data from the table and deal with it just as you would any other data. Some frameworks (like CodeIgnitor) do this for you by changing one configuration item.

    3.) Validate against IP – in your table, add the current IP address. If the current IP doesn’t match the one in the session, someone is probably trying to hijack. Force a logout and terminate.

    4.) Place limits on login attempts. Adding a 1 second sleep(); server side on each login is virtually unnoticeable to the user, but for an automated system, it makes it virtually impossible to brute force logins.

    5.) Watch being ‘too chatty’. In a login, you may think it’s helpful to give descriptive erros like ‘username doesn’t exist’ or ‘incorrect password’. Information like this tells a hacker that they have gotten a valid username – it makes hacking much faster.

    6.) Be less concerned about the safety of PHP and SSL and more of your own logic. Just because a website uses SSL doesn’t make it secure. SSL coupled with valid logic provides security.

    7.) If you’re SUPER concerned, you’ll want to move to a dedicated server. It’s possible that other websites hosted on your server could have access to your code/db information. They may not be taking the necessary steps to be as secure as you.

    8.) Don’t allow simultaneous sessions. This prevents a MITM (man in the middle) attack. Another advantage of the DB session approach is that you can force logouts if two clients are trying to login at the same time from different IPs. Yet another advantage to the DB approach is that it makes your system scalable (since session storage is filesystem dependent).

    9.) Use mysql_real_escape_string instead of add_slashes

    If you need more information on security with PHP, it’s a speciality of mine. Feel free to contact me.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.