session| Server
"Summary" to solve the session concept, I am writing for my unit a invoicing system found that need to allow multiple users to enter a PHP application at the same time. The original static unique session ID of the design resulted in data clutter. This makes it imperative to dynamically generate a unique session ID.
The so-called session is the first proposed by Microsoft, in the ASP, the first integration. Thanks to the adoption of the session, Web developers are greatly facilitated by their work. For a while the ASP swept the world. Now PHP4 also added support for the session, showing once again the power of open source. Similar to cookies, the purpose of the design session is to transfer data between different pages during one visit to solve the problem of stateless HTTP protocol, but it is simpler and more secure. There is no uniform translation in Chinese, and I am accustomed to translating it into conversation. The meaning of the session should be clear: in fact, when browsing a website, in the browser does not close the situation, a Web application start and end. A session can include several HTTP requests and responses, such as freemail.263.net, from login to logout or timeout as a session lifetime. Each created session has a unique identification string called the session ID, which is sent to the client and also generates the same unique identifier string entry on the server side, which is either placed in a text file or placed in a database. The program can then register some session variables under this SessionID. These variables, like general variables, can hold text or numeric information, which can be read out or written through the session. The unique identification of a session is typically a unique session ID within the system, typically a very long string.
The question is presented as follows:
After the session concept was solved, I wrote a invoicing system for my organization to find that multiple users could enter a PHP application at the same time. The original static unique session ID of the design resulted in data clutter. This makes it imperative to dynamically generate a unique session ID.
The solution is simple: I used the PHP filename + timestamp as the only session ID, so that every session in my program is in place and no longer confusing.
Below put my source code published, convenient also has the same problem friend one more solution.
Start a PHP session to preserve variables.
if (empty ($mysessionname)) {
$micro = Microtime ();
$micro = Str_replace ("", "", $micro); Strip out the blanks
$micro = Str_replace (".", "", $micro); Strip out the periods
$mysessionname = "Po_maint". $micro;
}
Session_name ($mysessionname);
Session_Start ();
Program Comment:
I use Mysessionname as the only sessionname transfer variable between pages, and if you use that name you have to make a small change to the program. Mysessionname cannot be the internal variable name for the session because he already existed before the session started. Mysessionname also cannot be stored in cookies, as multiple sessions will certainly overwrite the original cookie file. You can save it with an implied form field. So there's no problem. Welcome to the letter discussion. Let's do it Better Together.