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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:58:55+00:00 2026-05-15T11:58:55+00:00

Im using sessions for login systems in PHP. In all login examples, people directly

  • 0

Im using sessions for login systems in PHP. In all login examples, people directly uses “session_start()” function. But im confused about this.

=============================================

On localhost, I have that files;

http://localhost/app1/page1.php

http://localhost/app1/page2.php

http://localhost/app2/page2.php

=============================================

In app1/page1.php, I start the session and set a variable.

 session_start();
 session_regenerate_id( true );
 $_SESSION[ 'name' ]    = 'this is my name';

=============================================

In app1/page2.php and app2/page2.php, I start the session and get the value of that variable.

 session_start();
 echo 'name: ' . $_SESSION[ 'name' ];

=============================================

I open http://localhost/app1/page1.php and then http://localhost/app1/page2.php and it works great. But after that, I open http://localhost/app2/page2.php, and also it show “this is my name” writing on the screen and this is wrong. Because it’s another application and I dont want app2 to reach app1’s session.

How can I solve this problem? I don’t want to use different variable names for each application. There must be another good solution I think. I can regenerate ID at app2/page1.php maybe, but if a person tries to open app2/page2.php, after opened app1, they may get into the app2 and this doesn’t become good for me.

Thank you.

  • 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-15T11:58:55+00:00Added an answer on May 15, 2026 at 11:58 am

    You need to use session_name() before session_start();
    Example:

    app1/page1.php & page2.php

    session_name('app1_session');
    session_start();
    

    app2/page1.php & page2.php

    session_name('app2_session');
    session_start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a PHP login/register system, and the login sessions are done using...
Do i login using cookies or sessions in a login system? I've seen examples
Talking about Hybid Auth , I'm using Facebook to login the users, but I
I've created a login system using PHP sessions. Here's how it works: 1.) when
I have a website, im using sessions for the login. In every pages of
I'm trying to store the user's ID in the session using django.contrib.auth.login . But
I'm using login function in my site with session. This session of mine gets
I tried to make admin panel and I am using sessions , but have
I was creating a login system with PHP and I wondered: Why are sessions
I have a login form using jquery ajax and a php code. The issue

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.