How to make the site different files in the session variable exists in a session file

Source: Internet
Author: User
How to make the session variable exist in different files of the website in a session file
I'm now considering Session.save_handler = files.

I built two directories in the root directory of the site, Test1,test2, and put two test.php respectively.
test1/test.php
Session_Start ();
$_session[' other1 ']= ' other12012 ';
Print_r ($_session);
?>
test2/test.php
Session_Start ();
$_session[' other2 ']= ' other22012 ';
Print_r ($_session);
?>
After running these two files successively, two cession variables exist in a session file: The contents of the Sess_ file are: other1|s:10: "other12012"; Other2|s:10: "other22012";


But I found that sometimes a session file does not exist on the same site,
For example, I built a directory under the site to put a forum program, forum program session always create a new session file, rather than the other session with a session file.

I want all the PHP programs under the site to share a session file ...

------Solution--------------------
Create a new public include file, head.php, which writes session information and is included in the Test1,test2.

This way, no matter how many levels of the directory, it can be passed as long as it contains head.php.
------Solution--------------------
A visitor's Session-cookie exists in the visitor's browser for a server-side session file and a maintenance session.

Don't know what you want to be?

http://cn2.php.net/session_id

All pages use session_id to set the same session ID to ensure that all visitors share the same session-cookie (sesion ID) and that they will access the same server session file.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.