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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:36:35+00:00 2026-05-19T10:36:35+00:00

I am trying to secure my sessions. While doing some research, I reckoned that

  • 0

I am trying to secure my sessions. While doing some research, I reckoned that PHP’s PHPSESSID+random hash based on Agent and IP is good enough to secure against hijacking. What else can you do, really.

I am using HTTPS for the login. As far as I could understand, the session data from PHP is never sent to the user, but rather stored on the server-side. The client only gets the id for the session. The session data holds the actual webapp’s user session, which in turn is used to check if the login is valid. All fine and dandy.

However, there is a detail I can’t find anywhere. I would like to to know if the cookie containing the PHP session id is automatically marked secure if I am using HTTPS. I did some google searches but never seemed to get the right search string because i only find ways of manually sending cookies. I would like to know because if that cookie is sent clear-text, it would compromise some of the security via man-in-the-middle.

EDIT 1

This is an addition for @ircmaxell

I tried out your method but somehow I still get the cookie when I switch from HTTPS back to HTTP. The way it should work is the following. Whenever the server is aware that a user session is available, it sets the secure flag. This means that the entire site runs on SSL as soon as you are logged in and refuses to give away/use the cookie whenever you don’t use SSL. Or at least, that’s the idea.

if ($SysKey['user']['session_id'] != '') {
   session_set_cookie_params(60*60*24*7, '/', $SysKey['server']['site'], true, true);
}

I assume I need to regenerate the id since the Browser already had the cookie before the login but since I can only try it out in a few hours, I’ll ask here before trying

NOTES TO SOLUTION

I just found out that you have to set these settings before starting the session. That was my problem. I am now using 2 different cookies. One for the regular guest that is sent via http, and a second for logged in users that is only sent via ssl.

  • 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-19T10:36:35+00:00Added an answer on May 19, 2026 at 10:36 am

    I think the function that you’re looking for is session_set_cookie_params(...). It will allow you to set the secure cookie flag to make it https only.

    You can check via: session_get_cookie_params()

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

Sidebar

Related Questions

I am trying to create a more secure PHP sessions login script. Unfortunately for
I'm in the process of trying to make a secure PHP based login system
I'm trying to secure an application so that users can only see objects which
I am trying to authenticate to a server's secure URL using java.net.urlconnection - based
I'm trying to secure a older classic asp web site (that has about 1,000
So I'm trying to write a php SOAP client that requires the user to
I'm trying to create a secure session management where each user gets a hash
I am trying to secure a password with sha1 hashing to a saltMe() function
I'm trying to secure a WCF service using windows accounts. The service should run
I am trying to secure communications via SSL/TLS for one of our Web Service

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.