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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:36:02+00:00 2026-06-07T07:36:02+00:00

Is it not mandatory to use session_start() before using any session variables in PHP?

  • 0

Is it not mandatory to use session_start() before using any session variables in PHP?
I tried the following piece of code without declaring session_start() at the beginning, it worked fine.

So, now I’m confused. Please help !!!!

Also, I did not use any $_POST or $_GET to pass $uname to home.php, but still how does it work? If we use include ‘home.php’ then does it treat login.php and home.php as same page?

// code login.php//
<?
require_once 'db_connect.php';

if (isset($_SESSION ['user_id']) && !empty($_SESSION ['user_id']))
{

    $u_name = $_SESSION['user_name'];
    include 'home.php';
}
else
{
//some stmt
}
?>

/*******home.php file ****/

<?php
require_once 'dbconnect.php';
$_SESSION['username'] = $u_name;
//echo $_SESSION['username'];
//blah blah
?>
  • 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-07T07:36:04+00:00Added an answer on June 7, 2026 at 7:36 am

    You definitely need it, if session.autostart is not set in php.ini. But you would probably know that then.

    Do you not call it in db_connect.php? Also, I’m pretty sure you wouldn’t get any errors, the session would just be empty.

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

Sidebar

Related Questions

I am defining a Form class which has a filefield and is not mandatory
I've a form,in the form only few fields are mandatory.When a fields is not
Not ever sure if it can be done, but is it possible to use
NOT USING A XML PARSER I want to get the contents of the XML
I am using JSF 1.2 + Facelets + Apache My Faces without Tomahawk or
I use syntax like name varchar(20) NOT NULL in mysql..i have a big confusion
I've looked at Net::Google, and 90% of the modules use AuthSub with a mandatory
I have seen people use GO statement between batches of SQL code, but AFAICS
I know I shouldn't use Dev-C++ but it's mandatory in school so I can't
I am having a code like the following selenium.chooseCancelOnNextConfirmation() ; selenium.click(deleteRequest); // confirm dialog

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.