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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:15:16+00:00 2026-05-14T05:15:16+00:00

We may replace a PHP app with a Java EE app, but the problem

  • 0

We may replace a PHP app with a Java EE app, but the problem is we wanna replace the modules one by one, which means two apps would co-exist and communicate with each other.

So is it possible to share the user session between the 2 apps? Or use a cookie to solve the problem?

  • 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-14T05:15:17+00:00Added an answer on May 14, 2026 at 5:15 am

    Save your session data to a database with session_set_save_handler().

    UPDATE
    Efficiency wise it would be very mininal, the difference from reading a text file to querying a database (presumably using an existing connection).

    Some example code (simplified from what I use)

    class Session {
        public function __construct() {
            session_start();       
            $this->clean();        
        }
        public function __destruct() {
            session_write_close();
        }
        public function open() {
            return TRUE;
        }    
        public function close() {
            return TRUE;
        }    
        public function read($id) {
            global $Database;
            if ($Database->select('session_data FROM sessions WHERE session_id="%s"', $id)) {
                list($data) = $Database->fetch(MYSQL_NUM);
                return $data;
            } else {
                return '';
            }
        }    
        public function write($id, $data) {
            global $Database;
            return $Database->replace('sessions SET session_id="%s", session_data="%s", session_updated=%d', array($id, $data, time()));
        }    
        public function destroy($id) {
            global $Database;
            $_SESSION = array();
            return $db->delete('sessions WHERE session_id="%s"', $id);
        }    
        public function clean($expire = 600) {
            global $Database;
            $Database->delete('FROM sessions WHERE session_updated<%d', $time - $expire);
            return TRUE;
        }
    }
    // Declare the functions to use:
    session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'clean'));
    $Session = new Session;
    

    The you can read/write to the session data using $_SESSION['name'] = data; in the usual technique.

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

Sidebar

Related Questions

May be obvious but I tried searching and can't figure it out. I am
May i ask you how can i calculate the period by deduct two time
Introduction I am attempting to replace an on-call cell phone which is carried by
I'm working on one application ( using PHP, javascript ). Below is the short
I am trying to replace a certain word in php and include a whitespace
I'm totally new to PHP and MySQL but I'm implementing the Facebook PHP SDK
As part of a project, I need to analyse string which may contain a
Is there any PHP PDF library that can replace placeholder variables in an existing
I'm a bit lost for I'm green in PHP. Please, may you teach me
I have a php page which contains a large amount of HTML in it.

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.