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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:52:43+00:00 2026-06-08T12:52:43+00:00

I have two files: html php where html file is calling the php file

  • 0

I have two files:
html
php

where html file is calling the php file to do something.

Now i would like to get the PHP session ID (php code) into both my html file as well as my php file.

I would like to know how would I do so so that both html file and php file have the same PHP session ID.

Thanks for your help in advance.

  • 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-08T12:52:44+00:00Added an answer on June 8, 2026 at 12:52 pm

    You can’t have PHP sessions in HTML files. Best to just change the HTML file to a PHP file.

    As mentioned in the comments – make sure you start the session at very top of the file before any spaces before the opening php tags.

    To retrieve the session ID use php function session_id() but if the both files are on same domain you just need to call session_start at the very top and it’ll just use same session across.

    EDIT

    To answer your qs in comments below –
    Yes, a PHP file can just have HTML code but no PHP code at all or add PHP where required. e.g.

    Myfile.php

    <html>
    <head> ... </head>
    <body>
    <h1>some title</h1>
    ......
    ......
    <a href="#">Go to next page (<?php echo $_GET['next_page']; ?>)</a>
    ......
    </body>
    </html
    

    so you just open and close php tags where you needed php stuff to go.

    To print session ID – just use somewhere in the HTML of PHP file.

    Yes, session_id() will give you the same session ID in php2 file – again, make sure you call session_start function at the very top in the php2 file too.

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

Sidebar

Related Questions

i have two files trying to use ajax here is code of test.php file
I have three files in a folder 'test' one.php two.php print.html And i have
I have two files: master/newsletter1/file.html master/newsletter2/file.html newsletter1/file.html has a lot of new changes that
I have two files client.php and server.php. The client file send a HTTP request
On one PHP server I have two files. One file (the name is first.php)
I have two different PHP files that both write to the same file. Each
Here's the deal - I have two files, main.html and processing.php. Within the php
i have two php files where one is executed through url and that file
I have two files like below SomeClass.php class SomeClass { public function display() {
I have two PHP files: template.php template.html.php The first is the class definition for

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.