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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:19:08+00:00 2026-05-31T17:19:08+00:00

I am using the session_name to rename my session to lets says ‘xxx’. Using

  • 0

I am using the session_name to rename my session to lets says ‘xxx’. Using this I am also able to start a session using session_start. I also able see the cookie being set in my browser.

//TO SET session

login.php

session_name('xxx');
session_start();

But the problem is that I am not able to retrieve the session id using the session_id call in an another script.

another.php

session_name('xxx');

$id = session_id();
echo $id // This is showing empty

var_dump($_COOKIE) // This is showing the cookie xxx with the session id 

if(!empty($id))
{
  //If he is already logged in, lets get his details
  session_start();
}

I know that I can go ahead and read the cookie to see if the session is set. But I was just curious to know why this is not working. Isn’t the session_id function retrieve my session id after setting the session_name ?

We know the that session_start is going to open my existing session but on the other hand if at all there isn’t session then it will start a new one. I don’t want start a new session if it is not already started.

What am I doing wrong here?

  • 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-31T17:19:09+00:00Added an answer on May 31, 2026 at 5:19 pm

    There will be no session_id before you start the session with session_start.
    session_name just sets the cookie/URL param name, it does not start a session.

    And yes, you need to start() the session on every single page you want to use it.

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

Sidebar

Related Questions

I have two PHP scripts, both using the same session by calling session_name('MySessID') .
I have a PHP code which starts a session using session_start() . Well, after
Here is the piece of code: session_name('somename'); session_start(); echo 'session name:'.session_name(); The above does
I'm using session-based cookies with my website. To my complete surprise, I noticed if
public MyClass(int someUniqueID) { using(//Session logic) { var databaseVersionOfMyClass = session.CreateCriteria(/*criteria*/) .UniqueResult<MyClass>(); //Load logic
I have been using SESSION Variables to enter data with loginName as way to
I've got a load-balanced (not using Session state) ASP.Net 2.0 app on IIS5 running
I'm having some troubles using Session Variables as they are being used as Reference
I am confused with cookies and using session in servlets in jsp's and servlets.
I'm looking for best way of using session within zf application. At first 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.