answersLogoWhite

0

There's no "right" answer to this question (as with anything programming-related) but it should point you in the right direction.

Session support in PHP is accomplished through cookies by default (all of this can be overridden via code). Since you're unlikely to want to travel outside of cookies for your solution, you're restricted to whatever cookies will allow you to do (as with any language).

PHP stores a session-id in a cookie and on the filesystem by default. This means the cookie needs to be set so that your browser sends it to each server during a request, and that each server has access to the server-side store which holds the session data for each cookie.

If all servers share the same DNS name (service.domain.local) your browser will send it regardless, but if they do not (intranet.domain.local and applications.domain.local) you will need to use the session_set_cookie_params() function to set the domain to a common subdomain - i.e. ".domain.local". Be aware that this sends it to every web server matching ".domain.local" so other machines will receive your highly important session-id, so plan this out carefully.

Once the web servers are all receiving the cookie, your PHP installation will need access to a common storage location. By default, PHP stores cookies in a local directory with the filename being the session-id and the contents being the session data. Thus, you'd need to access/share the same directory on all machines or change that behavior. I'd suggest investigating the many ways you can move session storage to a database so all machines have reliable, safe access to the session store - and, you can report on those sessions down the road.

In short, it's a two-pronged approach: set the session cookie up so it reaches all of your servers (again not an issue if they all have the same hostname) and configure PHP to pull session data from one central place.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is the purpose of a PHP session?

A PHP session serves quite a few purposes. PHP sessions store data that the web application developer would like to have preserved across the different page loads.


What is the default extension that most Web servers use to process php scripts?

When processing PHP scripts, web servers most frequently use the.php extension by default. This implies that a web server will recognize and run PHP code when it comes across a file with the.php extension.


Write down a PHP code to add a session variable?

The preferred way is to simply alter the session superglobal. <?php $_SESSION['variable'] = "value"; ?>


What is a php session?

A PHP session is a concept where specific variables (and their respective values) are carried throughout a user's viewing of a PHP-driven website. These sessions can be initialized and continued using the session_start() function. The session values are stored in the $_SESSION global variable. For more information, see the php.net documentation of session functions.


What is a good server for PHP language?

The best server yet for php serving is Apache, as PHP and Apache work closely together. The MySQL community database is a good server for PHP applications, this is why we talk about w/xamp servers, Windows/Linux Apache MySQL PHP servers.


How do you maintain a session in a PHP quiz script?

All you have to do to maintain a session is start it before you call any variables. Once you've started the session, you can store variables for use in later scripts. Beware though, once the user closes the browser, the sessions' over. I'd use the following SCRIPT 1: <?php // Start session session_start(); // Set some variables (this simulates form input) $_SESSION['answers']['Q1'] = 18; $_SESSION['answers']['Q2'] = 36; $_SESSION['answers']['Q4'] = "Fred"; ?> ============================= Hope that helps...


What is the main competitor of PHP?

PHP generally competes with ASP.NET, although PHP is installed and used on a much greater number of servers.


How do you clear session?

To clear a session in a web application, you can typically use the session management functions provided by your server-side technology. For example, in PHP, you can call session_destroy() to terminate the session, or in Node.js with Express, you can use req.session.destroy(). Additionally, you can clear session data on the client side by deleting cookies associated with the session. Always ensure to handle user logout properly to maintain security.


What is php application server?

A PHP application server is a software platform that processes and delivers PHP scripts and applications to users. It interprets PHP code, manages server resources, and facilitates communication between the application and the database, enabling dynamic web content generation. Common PHP application servers include Apache with mod_php and Nginx with PHP-FPM. These servers play a crucial role in executing web applications built on the PHP programming language.


How can you get the session after the user logs out in PHP?

Depends what you mean with that. If the user logs out, the session gets destroyed, and with it the session ID. You'd need to grab the session ID before the user logs out.


What is xampp?

One of the web servers for php which supports coding in PERL programming


Which kind of service is php hosting?

PHP is a scripting language used for web servers and application development. PHP hosting is a web hosting service that allows for more complex site because is supports the PHP scripting language.