Error reading session data when try "Session::instance();" in Kohana - session

On localhost everything good, but on deploy there is an error "Error reading session data" when I try invoke Session::instance(). Where is my mistake?
Maybe it's server problem or Kohana bug?

In my case, its a server problem. I had similar problem yesterday, and this how i solve it.
first, set error handling to false (on bootstrap.php, set error => false) for better diagnose
refresh again your browser. mine had error writing on C:\xampp\tmp. It turns out my "tmp" folder was missing (i dont know why, probably misdeleting due bad mouse habit)
create tmp folder, done :)
btw, i'm using 'native' as kohana-session handler.
For xampp, you may check on xampp/apache/conf/extra/httpd-xampp.conf for "SetEnv TMP {your tmp dir here}". Other LAMP-stack may vary.

Can you post your session.php? Have you set your encryption key if you're using the encrypt option? What driver are you using to store the session (file, cookie, database)?

If you are using the database (or ORM) for sessions then "Error reading session data" usually means that Kohana can't connect to the database. Check that you can connect to the database.
If you are using files for sessions then check the the folder where PHP writes sessions is writable.

My problem was in session 'native' kohana 3.3. I got the error reading session data and broken data or something. When I check any data from $_SESSION array e.g. echo $_SESSION['x'] there was that value I needed, so why this told me about error reading?
The error appears on line: $session = Session::instance();
I tried many solutions (php.ini, for example) without success.
My first solution was:
try{
$session = Session::instance();
}
catch (Exception $e){//do sth. eg. restrt sesion etc..}
But this was bad solution because few months later the problem back to me on another server.
I got the message Database_Exception [ 1030 ]: Got error 28 from storage engine...
or Database_Exception [ 126 ]: Incorrect key file for table '/ramdisk/mysql/tmp/#sql_138c_2.MYI'; try to repair it [ SHOW FULL COLUMNS FROM tabe ]
So, when on your server there is no space for mysl storage files you get thta error "Error reading session data"
The solution is make some space on server. In my case I just delete few very old files and some log files.

Related

Unexpected Behavior in Laravel 7 with Storage::put() and fopen()

I am working on a solo project where admin users will be able to manage Virtual Machines via a web application run on laravel 7. I am currently creating the creation controller which requires uploading large files (.ovas). I am trying to use streams (I think) in a store method.
Specifically, a view has a form with a standard file inclusion that sends the request to the controller. The form gets validated and then I try to move the file into storage as such:
$data = $this->validator($request);
Storage::put('files', fopen($data['file'], 'r+'));
Where $data['file'] is the uploaded file. I can see the file being uploaded locally (while monitoring hdd usage), but after it is sent, laravel returns the following error
fopen(/var/www/html/devel/ocl/storage/app/files): failed to open stream: Is a directory
The error seems pretty obvious, so I was curious and decided to return the fopen() call before storage to see if I could invoke the same error by changing the method to:
$data = $this->validator($request);
return var_dump(fopen($data['file'], 'r+'));
However, no error is invoked and I get resource(8) of type (stream) as expected (I think). The tmp resource disappears and no errors are thrown. I am a bit baffled on why this is occurring as I would assume that function call resolves before the storage. I feel like I'm missing something fundamental with PHP/laravel and cannot think of how to continue to explore the issue.
Why does the first call to fopen() seem to see $data['file'] as a path, but the second call to just fopen() work as intended? I am hoping the answer can help remedy the issue.
Thanks!

"Error: Token Mismatch" After adding a 2nd server to phpMyAdmin

I've been searching and trying to solve this problem for about 3 weeks. I'm stumped. Please help!
I added a second server to phpMyAdmin by adding the following lines to the end of my "config.inc.php" file in the installation directory.
$i++;
$cfg['Servers'][$i]['verbose'] = '<SERVER 2 NAME REDACTED>';
$cfg['Servers'][$i]['host'] = '<SERVER 2 ADDRESS REDACTED>.rds.amazonaws.com';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Servers'][$i]['ssl'] = false;
After I added this server, we started getting the "Error: Token Mismatch" popup randomly when running some SQL queries or performing certain actions while logged in to server #2. We never got it on the first server we had set up for several years, and I matched all the server configuration settings to those of the first server. The issue is not 100% reproducible with SQL queries, but it does seem to be 100% reproducible when I try to add users to the database via phpMyAdmin's user creation page.
Steps:
log in (select server #2 in the "Server Choice" drop-down menu)
click "users" tab at top of page
click "add user" link
fill out the required fields and click "go"
At this point I always get the "Error: Token Mismatch" popup.
Things I've tried so far:
clear cache / cookies (I do this every time I change settings)
use different browser (tried Chrome, Firefox, and Safari)
change ";session.save_path" variable to “/tmp” in php.ini file
Do "chmod 1733" on the sessions save directory
Made sure there is free space available (19GB free)
After all this, we still get the error.
Software:
PHP: 5.3.29
Apache: 2.2.23 (Amazon)
SQL type: 10.1.23-MariaDB
Database client version: libmysql - 5.5.24
PHP extension: mysqli
phpMyAdmin: 4.2.2
Hardware:
phpMyadmin server hardware: Amazon EC2 m3.large
SQL database server hardware: db.m4.2xlarge
Any suggestions for places to look or things to try are greatly appreciated.
One thing that caught my eye is that you mention the ;session.save_path variable; the semicolon in front of it is a comment so for the directive to be recognized you'll have to remove the semicolon. Check the output of phpinfo.php to verify that the change was successful.
Other than that, it's tough to guess. You're using an old PHP and old phpMyAdmin version, so I'm not saying an upgrade will or won't fix the problem, but you really should upgrade.
One workaround would be to have two phpMyAdmin installations; you can have phpMyAdmin in two different folders, with each one pointing to a different MySQL server. It sounds like it was working fine with one server so if you do it this way, each instance will only have one server and hopefully you won't have the problem.

RmGetList consistently returning 0x5 ERROR_ACCESS_DNIED

I am getting consistently a return value of 5 from RmGetList, any possible reasons?
I am following this tutorial: http://blogs.msdn.com/b/oldnewthing/archive/2012/02/17/10268840.aspx
My RmStartSession and RmRegstierResources both return 0 which means success. A note though, after RmStartSession the dwSession is always 0, and my szSessionKey stays a string in the form of 0ea790d06656a54f84645b5755f7b6d6 null terminated. Is this a problem?
My code is js-ctypes so I'm reluctant to share this in winapi but ill share it: https://github.com/Noitidart/_scratchpad/blob/master/_WinAPI-RstrtMgr.js#L293
Edit: I learned that dwSession of 0 is a valid. However I still can't figure out why I'm getting access denied on RmGetList, anyone any ideas?
I've learned that the restart manager doesn't support folders, and the error 5 is returned when you're trying to pass a folder:
https://blog.yaakov.online/failed-experiment-what-processes-have-a-lock-on-this-folder/
Update: here's some sample code of how to use the restart manager API:
https://github.com/Microsoft/msbuild/blob/master/src/Tasks/LockCheck.cs
RmGetList will return error 5 if any higher level thing like a file system fillter block the file
the driver filter denies access to file xxx from any process and function whether windows kernel or user code tries to access it
it does the same with restart manager , restart manger tries to access the file , the driver throws error 5 , the restart manager wont know what to do with it ,and rethrows it back to calling function ,so you'll get a access denied
if you are trying it for all files in windows volume, there will be much files with throwing error 5, including 3rd parity antivirus files or ms defender or ...
simply use a try catch and ignore them because even if you know what pid is locking them you couldn't do anything about it, other than watching
it also happens if you don't have even read access to the locked file ,in this case try fixing security permotions and trying again

Magento Admin Backend Blank Page after login

i have a serious problem in Magento Admin Backend. After login its shows a BLANK Page. i used the same files and database in different server, there it was working fine but when i have transferred files into LIVE then Admin issues came. Please help me over this as i got frustrated from last some dayz. If you need any more dertails then plz ask but i need to resolve this soon. Link: http://studywings.com/index.php/admin/
Magento ver: 1.7
flush your magento root /var/cache folder and /var/session folders, It may have previous server session that may cause problems.
Otherwise disable all third party modules and try again. I think this will help
I had the Same problem,
i have also debug the any errors occured, i tried index.php file
ini_set('display_errors', 1);
error_reporting(E_ALL);
$_SERVER['MAGE_IS_DEVELOPER_MODE'] = true;
pleced above code in index.php file. after that i have tried admin login.
showing the errors are session related, header already send errors.
i have to add the code in root/index.php file in top add the following line.
ob_start();
after that tried the login its worked.
Cheers..!
Is url changes to this after click login button or not?
http://yourdomain.com/index.php/admin/index/index/key/(key value)/
if url changes but not not show the dashboard page then go to
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
make copy of this file
Find the code for setting session cookie parameters these started on line 77
Comment out the final three lines and be sure to remove the comma after $this->getCookie()->getPath(). You should end up with this:
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
// $this->getCookie()->getDomain(),
// $this->getCookie()->isSecure(),
// $this->getCookie()->getHttponly()
also line 104 comment out :
//call_user_func_array('session_set_cookie_params', $cookieParams);
If there is no change in url after click login then try to uncomment display error and see error_log file of your server
I think this problem is due to file permissions. As you added files from one server to another, permissions might be get changed.. Try to give the permissions to all the files. Check this http://www.mage-shop.com/forum/threads/3-Magento-Admin-Backend-Blank-Page-Error
There are a number of things that can cause it, but it's most common after migrating to a new server, last time it happened to me it was an excessively low php memory_limit setting on the new server - the Admin part of the site uses a lot more resources per user than the frontend.
In general when having this issue:
Flush out your cache by emptying var/cache
Clear out sessions by emptying var/sessions
Check the magento error logs/reports for an error code in var\logs and var/reports
Turn on magento error logs in mysql if logging isn't already on! (look in core_config_data for WHERE path like 'dev/log/active'
Check if your php configuration is displaying errors
Check your apache/php error logs for more clues - memory errors will show up here for example
Try this solution
It sounds like you want to enable Developer mode. Add this to your .htaccess file:
SetEnv MAGE_IS_DEVELOPER_MODE "true"
You may also want to enable display errors in index.php:
ini_set('display_errors', 1);
The best way I have found to debug is with X-Debug in a local environment. You can also use log files to help debug in a production environment, if your unable to run X-Debug in the environment.
I've got a more detailed posting here:
http://www.molotovbliss.com/debugging-tips-and-tricks-with-magento-commerce
Consider also installing XDebug
Hope this helps you!
Just to complete the other answers....
I am upgrading a magento install, and got the same problem, in the end I had another folder inside of var/
magento/var/minifycache
Only worked after clear deleting the files inside of this folder.
I had the same problem after uninstalling an extension. I thought that clearing cache would be enough, and I did without success... later speaking with the technical team, they commented me that it did not work because I hace memcache installed, and needed to be done the cleaning via system - backend (that i coudl not see...)

codeigniter session data gets lost

i already posted this question but still wasnt able to resolve this issue.
seems that everyone has this problem with codeigniter .
When i set my session in a controller it works perfectly and i can display it.
WHen i move to another controller, the (CUSTOM) session data is completely lost.
i tried changing my cookie_domain in config.php. Since i am on localhost i tried localhost with without / and localhost/codeigniter and sodeigniter all did not work. i am lost
btw, i read somewhere that this happens when 2 ajax requests happen at the same time. could that be the problem?
Or maybe tell me how you resolved the problem if you had same issues
screw this, i am swithing to php native sessions. if anyone wants to do that,
http://codeigniter.com/wiki/PHPSession
Check and double-check your code or any external libraries you are using for a stray sess_destroy(). I ran into a similar problem where I was storing an id in the session for reference but if the user then logs in the SimpleLogin library I was using for logins just destroys the entire session including data I did not want to lose.
This is what I get for not writing my own code.

Resources