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

  • Home
  • SEARCH
  • 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 8166945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:03:21+00:00 2026-06-06T20:03:21+00:00

I learned about $_SESSION about several weeks ago when creating a login page. I

  • 0

I learned about $_SESSION about several weeks ago when creating a login page. I can successfully login and use it with variables. Currently I am trying to understand $_SESSION and $_COOKIE. Please correct me if I am wrong, I can use $_SESSION when logging in and moving around pages. With $_COOKIE, it is used to remember when I last visit and preferences.

Another thing involving cookies is that when websites use advertisements (for example: Google AdSense), they use the cookies to track when visitor click on a advertisement, right?

I can use both ($_SESSION & $_COOKIE)? I read somewhere that you can store the session_id as value for the cookie.

Also, I read about security which let to me finding this: What do I need to store in the php session when user logged in?. Is using session_regenerate_id good for when a user comes back to the site?

And this: How to store a cookie with php involving uniqid.

For those wanting to know about the login, I use email and password. That way the user can be able to change their username.

I look forward to learning more about these two from anybody who would like to share their knowledge about it. If I asked too many question, you can just answer the one that you have more experience with.

If you need more information, just ask since I might have forgotten to include something.

Thank You.


Found this: What risks should I be aware of before allowing advertisements being placed on my website?

  • 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-06T20:03:24+00:00Added an answer on June 6, 2026 at 8:03 pm

    In simple terms, $_SESSION and $_COOKIE are different.
    Both are php globals but cookies are used without a language limitation.
    $_SESSION is all about storing the data in the server while storing the session ID as a cookie. $_COOKIE is the cookies that browser sends to the server. This is the major difference. Sessions don’t work if the client browser has cookies disabled.

    – Security –

    If you checked request headers that your browser sends, you will notice that each request has cookie information in it. They can be tracked by snipping your network communication.
    Anyone with a better tools can edit cookie data.
    never use cookies to store passwords!
    If you use sessions, passwords are in the server and only the session id cookie will stored be in the client, reducing the security problem. Chuck Norris still can hijack a session.

    – Performance –

    If you store 5 cookies in the browser with 200 bytes in it, that cost ~1 KB of data on each and every request no matter if it’s a jpg file or a page that actually needs the cookie information. So this directly affects how fast your site can perform to the end user.

    if you use sessions, server has this 1 KB data while the client sends the session ID in each page request.
    You can be clever by shifting static files to another cookie-less domain.

    – Lifetime –

    Sessions gets cleared on timely basis. So if you want to save something for a long time, use cookies instead. “remember me” functionality of most sites works this way (still, it doesn’t store the password. Just the session information – not to confuse with session ID).

    Bottom line,
    sessions and cookies are different types. session is relatively secure and server side storage. gets cleared often. Cookies can have a larger lifespan but it affects performance (not CPU/RAM — load times) unless you don’t keep that in mind.
    It’s extremely strange if there is a reason to store 1 KB as cookies though.

    Never trust user input that comes through $_GET/POST. Do the same care for $_COOKIE as well.
    And there is session hijacking. Someone can guess someone else’s session ID although it’s nearly impossible to do. So use some validation at the server side first.

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

Sidebar

Related Questions

I just learned about jquery's .makeArray and I am trying to use JSON.stringify to
I recently learned about CTE's in SQL Server and am attempting to use it
I learned about location tag that can be used to disable the inheritance for
I learned about flashdata and decided to use it to display messages based on
I just learned about the 4k demo scene contest . It consists in creating
I just learned about arrays but can't conceptualize arrays with more than three dimensions.
Okay, I learned about this query 2 days ago:- SELECT SUM(DTotal) AS Monthly FROM
While I was reading about session hijacking articles, i learned that it would be
I just learned about comet pattern(Long polling) and very curious to implement a simple
I recently learned about IKVM.net which is a Java for Mono (.NET). So I

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.