for some reason that I can't figure out my Laravel install has started created a new session file on every request! This renders the session useless and so I users can't stay logged in, csrf tokens don't match etc.
I'm using Laravel 5.2. It seems fine on my local environment but not on the live server
Does anyone have any clues on why this might have happened and how I can resolve it?
Thanks in advance
Locally everything worked, but not on the production server. The problem was in the php.ini settings on the hosting, by default the parameter (variable) "mbstring.func_overload = 2" was set there. I removed it and than all worked. This parameter is for previous versions (PHP) which is used by many CMS. And Laravel gave an error 419 during authorization and nothing more, and created a new session every time the page was updated.
after the upgrade from 5.1 to laravel 5.4 I had a similar issue,
I found that I didn't upgraded app/Http/Kernel.php correctly.
\Illuminate\Session\Middleware\StartSession::class
was declared twice in protected $middleware array
and in
protected $middlewareGroups
after removing it from $middleware array
it started to work correctly
$middleware applied to all routes
and $middlewareGroups applied to specific groups
Check this issue - there's a change in Laravel 5.2.27 that automatically registers the web middleware for you, so if you manually use it in your routes (which you had to in 5.2) then it breaks.
This seems to be quirk of PHP + MacOS. It was a blank line before <?php in our index file. Absolutely ridiculous issue with hours lost on debugging.
My problem was that I was testing locally on the subdomain of the production site.
My local Laravel was at dev.example.com (mapped to localhost), and prod was at example.com. Prod cookies interfered with the development site.
Solution: clear interfering cookies OR move dev site away from subdomain.
have you checked this thread laravel forum
its says to check if there is any blank line before the <?php tag in the file
app/config/app.php , if any remove the blank line
I have just had this problem and it was caused by using dump().
This was sending output to the browser (just as whitespace before php tags would) and causing my session to break.
As others have mentioned, this happens a lot when a session can't start because headers have already been sent to the browser (The session_start function needs to send out several HTTP headers).
It can be due to a space or newline character before an opening <?php tag in any file.
Instead of searching for the culprit, this can be easily solved by enabling PHP's output buffering.
Look for the output_buffering directive in your php.ini and change it to
output_buffering=4096
This is the recommended value for production servers anyway and it may already be defined in OP's local env so the session works there as expected.
Related
I'm getting this at the bottom of my page, where the debug bar should be. What is the problem?
This request: http://localhost:81/xxx/web/debug/default/toolbar?tag=5578f180963e82.28312577 is returning 404.
I need to see the error message & stack trace generated when I log to Yii::error(). It's not showing in runtime/log/app.log, so I need the debug bar.
I removed files from frontend/runtime/debug and frontend/runtime/cache and nothing was changed.
But when I removed all folders from frontend/runtime then it started to work.
One reason could be missing write permissions for the runtime folder. The Debug Tool Bar creates there another directory debug which is used for *.data files.
This happens easily if the web server has its own user which differs to the user that has created the runtime folder.
I tried the info above without luck (and I suggest people here do the same, as in most circumstances it will solve your problem). But what worked for me was running.
tail -f frontend/runtime/logs/app.log and it told me that there was an error with a table that it expected to exist but did not. Once I fixed that underlying issue my problem went away.
In my specific case, I had the following enabled but no corresponding table/s.
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
Once I commented/removed it from my config, everything started working.
i tried the removal of runtime folders but it didn't change a thing
but a composer update fixed it for me
Another reason for it not working is attaching HttpBearerAuth filter to the main application (not a specific controller).
After removing the global filter, it suddenly works again. Not sure how to make it work with the filter. I will update this answer if I ever find a way.
Give read/write/execute(777) permission to your project folder. This will work for you. It works for me.
Upgrade of yiisoft/yii2-debug library to latest version resolved issue in my case.
I am having a problem with the session with the web development framework Kohana 3.2 that apparently is a bug that, at most, can be workarounded. It reports SESSION_EXCEPTION [ 1 ]: ERROR READING SESSION DATA.
My Kohana application isn't in the root folder and I wonder if that has something to do with it.
I have tryed several possible solutions but none of them have worked. Here are some of them:
1) using one library (Facebook SDK), session was initialized on it's own, and session handling was done using the $_SESSION variable. So there were two cookies - session (Kohanas session id) and PHPSESSID. *=> There is only one "session" and "PHPSESSID" variables in $_COOKIE*
2) Workaround or solution was setting in php.ini session.auto_start = 0. => I am working in a shared server (iPage) and I am pretty sure I can't edit the php.ini file.
3) some user's session files were trying to get saved to a directory that didn't exist. So he changed the session.save_path to a valid path and that fixed it. => If he was talking about this php native function , I've created a directory and set it calling this function as the session folder. It didn't work as well. However, I got unsure if I did it correctly (the path "/" would be the root, and not where kohana is in, right?)
4) Apparently this bug is reported to kohana here but I wasn't able to act from reading it.
Is somebody out there able to help me? Thanks in advance.
After researching very much about it and upgradion to KOHANA 3.3, I came to the conclusion that this error was caused when the native function session_start() was called in the Kohana_Session_Native class. It was caused because PHP was trying to save the session in an unavaiable directory. Thus, i just changed this path in php.ini and everything was solved. You may also just call the function session_save_path('YOUR_PATH') in the application/bootstrap.php.
in my case, i run "chmod 777 -R /path/to/session" command and the error has disappeared.
Alright, my application has been running fine for a few months now. Starting this morning all of my custom routes no longer work.
Have a controller named 'stuff' in a folder named 'mL'. Set up a custom route:
$route['default_controller'] = "mL/stuff";
Then visit 'website.com/', works fine, gets me to the 'controllers/mL/stuff' controller. Now, if I try to use a custom route:
$route['stuff'] = "mL/stuff";
and visit 'website.com/stuff' I get sent to my 404 page (as set in $route['404_override']).
This is true of all of my controllers, if I set it as the default_controller it works without issue. Someone else upgraded the server to php 5.4.9 over the weekend, and it's the only thing I can think of that might affect this, but I can't figure out how/why.
I dont think a php upgrade in itself would do this but something else must have had a tinkering.
Only thing I can think of is the htaccess or the apache config/setup has been changed - perhaps all or part of your htaccess is no longer working as a result (e.g. mod_rewite no longer enabled)
Either try restoring index.php in the config and the url to see if the page loads?
Can you check if mod-rewrite enabled. Check httpd.conf is set to allowOverride ALL for your directory and that the mod_rewrite line is not commented out.
check here for full details: http://www.tildemark.com/enable-htaccess-on-apache/
In future, if it aint broke, dont update it!
Same happened with me, couldn't figure something out but i rolled back to php 5.3.x and it will work again until we get proper update for this from codeigniter team but last update was like the below
I highly doubt that this is PHP-related. I'd guess that another
version of Apache (and mod_rewrite) is used with PHP 5.4 and I'd look
into httpd.conf and/or .htaccess
by narfbg
I've set up a new server for my magentocommerce.
Unfortunatly when I moved the domain to the new location (tests have been done using another domain) a weird issue started happening: when the login page displays on the frontend, or the backend and I (and customers, of course) do submit the right credentials the page refresh, the cookie gets set but the form is displayed again. It's such a cache being served instead of the right content (catalog).
The only solution actually is delete the cache on the browser and retry.
I've used varnish http accelerator for two days, but since I've had too much issues dealing with it I uninstalled it and cleaned things up (now there's only the apache instance to serve user requests).
I also installed APC caching and Fooman Speedster.
What can it be to cause this issue?
Can you please help me to get in the right direction to fix this issue? On the old server it was not happening, but since that time there have been some modification to the store (nothing to do with authentication anyway).
The apache error log does not report anything, the only thing in there is PHP: syntax error, unexpected BOOL_TRUE in /etc/php5/apache2/conf.d/apc.ini on line 4 which has to do with the line apc.enabled = 1.
Look at the System -> Configuration -> Web tab in the admin panel and see if the Cookie Path and Cookie Domain are set correctly for the new server. You can do it directly in the database as well. In this case, search for rows with web/cookie/cookie_path and web/cookie/cookie_domain paths. Setting them to empty values in the admin panel or NULL in the database may also help.
You should also clear Magento cache (System -> Cache Management) and APC cache (here's how to do it: How to clear APC cache entries?).
I don't know if it solves your specific form problem but we had the same error in the apache error log.
Our failure was, we've copied the apc.ini code from http://magebase.com/magento-tutorials/speeding-up-magento-with-apc-or-memcached/. They use "#" for comments.
Turns out we had to use ";" for comments. After these changes, there were no more errors in the apache error log.
I have a problem where i am losing the PHP session between 2 pages.
The session_start() is included in a file called session-inc.php into every page requiring a session to be set. This works for all pages on the site except one particular page, member-profile.php. When this page is visited a new session with a different id (same session name) is set and used instead.
A few more details:
Session name is set manually
All pages are on the same server under the same domain name
If i put an additional session_start() above the include('session-inc.php') in the member-profile.php file, the session is carried over correctly
I have tried setting the session_cookie_domain and session.session_name in the .htaccess, this worked for this domain but it stopped the session being passed over to out payment domain
We are running apache 2.2.6 with php 5.2.5
Putting the session_start() above the include('session-inc.php') in the member-profile.php file is the quick and dirty fix for this problem, but i am wondering if anybody know why this would be happening.
Cheers
Will
According to PHP documentation, session_start must be called before any output is sent back to the browser-- could this page have a rogue CR/LF, Unicode byte-order mark or similar that is causing output before you include('session-inc.php')?
While migrating a legacy site from PHP4 to PHP5 I noticed a php.ini configuration setting that causes php to auto-start the session upon every request. It's an alternative to placing session_start() onto every page...
There are multiple ways to enable this setting:
Put the following line into php.ini:
session.auto_start = on
or put this into your apache virtual-site config or .htaccess file:
<IfModule mod_php5.c>
php_flag session.auto_start on
</IfModule>
and it should make $_SESSION changes available across all pages
I have just encountered this problem. Interestingly, browsing via http://127.0.0.1 instead of http://localhost helped me.
I just spent all day diagnosing this issue in my Ionic3 - to - PHP project. TL; DR - make sure your client is actually sending session credentials.
In the interest of helping anyone who makes this mistake, I will share how I found the problem.
I used these tools to diagnose the session on both the client and server:
1) Add a test file with phpinfo() to the server to review PHP session options.
2) Review the PHP code to make sure that no output, intentional or un-intentional occurs before the session_start() line. Check the status bar of Visual Studio Code to make sure the Byte Order Mark (BOM) is absent from the PHP files.
3) Review server PHP logs (in /var/log/nginx/error.log for me). Add error_log() lines to the php file to dump the session_id() or $_SESSION array.
4) Use tcpdump -An 'port 80 or port 443' to view the actual HTTP requests and replies. (That's where I discovered the missing cookies).
For an Ionic3 data provider the correct syntax for the client is:
var obsHttp = this.http.post(url, body,
{ headers: new HttpHeaders({
'Content-Type':'application/x-www-form-urlencoded'
}),withCredentials: true }).timeout(this.timeoutTime);
Notice the withCrentials:true
One needs to call subscribe on the obsHttp() observable to send the request.
Found the issue
There was a byte order mark at the beginning of the main includes file of the second domain. as stated by ken, cant have any output before a session start, it was not setting the session correctly.
SOLUTION:
session.auto_start = on
in file: php.ini
It solved the issue of re-generating session id on page reload (page refresh / change pages).
The issue appeared after the update of CPanel (and included Multi PHP), even the php version remained the same.
The PHP.ini file didn't had that variable at all.
Went in Cpanel -> MultiPHP INI Editor -> Editor Mode (not Basic, in basic you do not have this setting) and added the line. Press Save.
TIPS / WHEN TO USE THIS SOLUTION:
To determine if that is the problem, put a line at the very beginning and at the very end of your index.php file to check the session id. Use function:
session_id();
Navigate through pages / reload the page. If the session_id value changes the problem is not in your code and this solution should solve your problem (the session is lost outside of your code).
I also tried to verify the availability of saving session on the web server (session.save_path) but, even if it was a lead, it was not the case.
I imagine this is a "feature" of Cpanel with MULTIPHP UPDATE that will happen quite often.
I had this problem, and the cause was that PHP was ignoring all cookies after the first 100. (I asked this question to try to find out why, but so far nobody has figured it out). The browser was sending the PHPSESSID*, but since it was the 110th cookie, PHP was ignoring it.
To figure out if this problem is what's affecting you, use your browser's dev tools to look at the cookies that the browser is sending with the request, and compare that list to the $_COOKIE array in PHP. They should be the same. But if the browser is sending a PHPSESSID*, and there's no PHPSESSID* in $_COOKIE, then that would explain why sessions aren't working.
I solved the problem by not having my site use so many cookies, which is good practice anyway.
*PHPSESSID is the default session name. Your site may use a different name.
To solve the session_id change after each request, you change the parameter session.auto_start and session.cookie_httponly into the php configuration file.
to find the used php configuration file
php -i | grep "php.ini"
then you open it, and try to find the parameter session.auto_start . you set
session.auto_start = 1
session.cookie_httponly = 0
finally you restart your httpd/apache service.
Found the issue
In my case it was due to Varnish Settings please check your varnish settings. PHPSESSID you can exclude the cookie from the Varnish Settings.
I'm not an expert, but found a solution after careful investigation of domain name in the cookies info of two webpages opened on Firefox. (Right click on the page, select inspection and the storage). checked domain names and found that one with www.example.com and the other without www (example.com). changed all the page links to same format and the problem solved for my case.
Found the problem was a byte order mark (BOM) being ouputted at the start of the file. Got rid of it and it sorted out the session problem.