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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:30:19+00:00 2026-05-28T19:30:19+00:00

I have a form with a fairly large amount of input that will also

  • 0

I have a form with a fairly large amount of input that will also be high traffic.
I declare $_SESSION vars so that on validation fails data that passes doesnt have to be rewritten out of convience to the user.

After I validate my form input like this:

$hey = htmlspecialchars($_POST['hey']);

if( correct_value($hey) == TRUE ) {
    $_SESSION['hey'] = $hey; 
}

I now have two variables with the same value in the same method where I update the db etc.

My question, is it faster from then on within the method to work with a:

$hey; //regular variable

Or a:

$_SESSION['hey']; //session variable

Is there a difference in performance? At high volumes does one perform faster than the other?

  • 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-28T19:30:20+00:00Added an answer on May 28, 2026 at 7:30 pm

    I haven’t done any benchmarks on this, but I strongly suspect that $_SESSION[] will always be a little slower than normal variables for writes, because it’s backed by the filesystem or database. Even if all $_SESSION[] storage is cached, there will still be more CPU and memory activity involved in using it than in using variables that are only held locally. For reads, there will still likely be a small difference, but it’ll be negligible compared to other factors.

    So the comment above is right on the money. You have other areas of optimization that are more important than this one.

    If you’re looking to improve performance, consider duplicating some of your input validation in JavaScript. (Don’t REPLACE server-side validation, as JS is not universal; just consider ways to avoid requiring it if possible.)

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

Sidebar

Related Questions

I have a form with several fields that will be a fairly active. With
I have a fairly large input form with a number of ASP.NET Validators on
I have a form generator that uses (perl compatible) regexes for ther backend validation.
So I have a fairly large form with two different sections. Both sections start
I have two GridControls on my form. One is a fairly large dataset, including
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I have this fairly simple form: <form action=...> <div> <input type=text class=input-text value= name=text
I have a fairly simple form with a checkbox, and I noticed that my
I have a form showing progress messages as a fairly long process runs. It's
I'm fairly new to ASP MVC so go easy :). I have a form

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.