session_start seems to be very slow (but only sometimes)
Have you tried session_write_close();
?
This will disable write-ability in session variables but you can still read data from them. And later when you need to write a session variable, reopen it.
I have also suffered from this problem but this thing worked like a charm. This is what i do:
session_start(); //starts the session
$_SESSION['user']="Me";
session_write_close(); // close write capability
echo $_SESSION['user']; // you can still access it
Problem with function session_start() (works slowly)
The file containing the session's informations is locked during the time PHP serves a request.
So, if you have one PHP script (using a session) that's currently being executed, and the same user sends another request, the second request will wait until the first is finished.
session_start() takes long time and makes pages pending
Solution: session_write_close(); and PHP Session Lockes
<?php
// First File
if(session_id() == '')
session_start();
session_write_close();
sleep(10);
Zend_Session::Start intolerably slow (but only sometimes)
Take a look at your session garbage collection mechanism (play with probability and divisor).
If gc is slowing down the app, consider cleaning the old sessions manually (e.g. setting gc probability to 1 and running gc script via cron).
Another possibilities:
- session mechanism is locked (so the app waits to unlock, then write)
- too much data saved
Related Topics
Verify Password Hash in Nodejs Which Was Generated in PHP
Matching Src Attribute of Img Tag Using Preg_Match
Laravel Error: Method Illuminate\View\View::_Tostring() Must Not Throw an Exception
Search and Replace Value in PHP Array
How to Check If a File Exists on a Remote Server Using PHP
Concat Columns with Laravel 5 Eloquent
How to Swap Colors in Image Using Gd Library in PHP
How to Return Custom Error Message from Controller Method Validation
$_File Upload Large File Gives Error 1 Even Though Upload_Max_Size Is Bigger Than the File Size
How to Escape String from PHP for JavaScript
How to Use Prepared Statements with Postgres
How to Use PHP In_Array with Associative Array
Mp4 Plays When Accessed Directly, But Not When Read Through PHP, on iOS
PHP - Create Simple Animated Gif from Two Jpeg Images
How to Decode Numeric HTML Entities in PHP
HTML Form PHP Post to Self to Validate or Submit to New Page