I'm facing a really weird issue with an application i'm working on based on symfony2 (2.5).
Long story short:
in the config.yml file i have this:
framework:
...
session:
name: "a_given_name"
# THE FOLLOWING LINE CAUSES THE PROBLEM
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/sessions"
cookie_lifetime: 2629744 #1 month
gc_maxlifetime: 2629744 #1 month
...
And session does not work!
I checked everything, the system create the files but those files are always empty.
Changing the entry realated to "handler_id" in config.yml to: "~" everything works fine.
framework:
...
session:
# CHANGING TO THE FOLLOWING -> IT WORKS
handler_id: ~
...
But, as stated in the docs, the "session.handler.native_file" is the default hanlder... so it should work anyway...
Any help about it?
Thanks a lot...
I faced the same issue when running Vagrant machine.
I recommend to move sessions out of the synced folders (default /var/www/html) to new location, e.g. /home/symfony/sessions
framework:
session:
handler_id: session.handler.native_file
save_path: "/home/symfony/sessions/%kernel.environment%"
Also, helpful article:
https://coderwall.com/p/h3i5mw/symfony-session-problems-with-vagrant
Related
I have this code in framework.yaml :
session:
handler_id: ~
cookie_lifetime: 43200
gc_maxlifetime: 43200
I want the session to be alive about 12 hours, but after some minutes the session expire. What else modification should I do ? Thx in advance.
If I remember right, your current configuration make PHP save session files inside /var/lib/php/sessions and this directory always checked and PID inside it removed by a cron job configured in php.ini via gc_maxlifetime.
To fixed this issue you have to override the session handler and make Symfony handle the session using handler_id and save_path option as the following:
framework:
session:
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
cookie_lifetime: 43200
gc_maxlifetime: 43200
I have a Symfony instance running on Linux with apache y NGINX. I'am starting the project using the built-in server:start command:
php bin/console server:start
Back to my browser, it loads me the Symfony start page but it also shows me the debug bar.
I have checked the config_dev.yml file and I think it is correct:
imports:
- { resource: config.yml }
framework:
router:
resource: '%kernel.project_dir%/app/config/routing_dev.yml'
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
However, if I try to access another route that I don't have, the debug bar is also shown:
You can access the prod env with:
http://127.0.0.1:8000/app.php
And accessing http://127.0.0.1:8000/app.php/a will give you an error page without the debug bar.
It is designed like this because the Symfony built-in web server is only meant to be used in development not in production. So the default environment is the "dev" one.
I've installed on my Ubuntu server, Symfony 3.3.6.
The problem is that it shows me the default page, also if I delete all code on "index.html.twig" or if I edit the code with my code. If I add views and Controllers, Symfony doesn't consider them and it shows me a 404 error.
I can't understand why and I don't find any error in config.php or app.php files.
I've also tried to set auto_reload: true on my config.yml but it doesn't matter... what I've to do? I'm quiet desperate...
EDIT: I've forgotten to say that if I delete index.html.twig, it shows me an error, so I'm not in wrong path
My twig parameters in config.yml
twig:
# debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
auto_reload: true
debug: true
cache: false
Sounds like you might need to clear the cache
To clear the dev cache do
php bin/console cache:clear
To clear the prod cache do
php bin/console cache:clear --env=prod
You can also tell twig not to cache like this. Amend your
# app/config/config_dev.yml
twig:
cache: false
debug: true
This assumes you are working in the dev environment
If you don't see the debug toolbar at the bottom of your web pages then you are probably working on a prod environment. In that case you may need to move that twig config to your app/config/config.yml
I just follow this tutorial. I created a new controller but my web debug toolbar doesn't show up. I accessed it via app_dev.php file, like , myurl/web/app_dev/contact/ even if i access my url without the contact the web debug toolbar doesn't show up.
This is my config_dev.yml file:
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
#swiftmailer:
# delivery_address: me#example.com
Do i need to do some extra settings ? I'm totally lost. Thx in advance.
Double check that you are actually accessing app_dev.php. For example try renaming app_dev.php to a new name 'app_dev_temp.php', then try reloading the page. If you can still access the page you are not where you think you are.
Also check your .htaccess file, if you are using a real server instead of the Symfony built in server, by default the htaccess will direct you to the app.php, not the dev version.
I have set the gc_maxlifetime in my config.yml file to 300. But its not working. Symfony2 still takes the value set in php.ini
Symfony version is 2.4.4
Try setting the cookie_lifetime parameters of the session config key.
session:
cookie_lifetime: 300 # override php.ini config
as described here
hope this help
Here is my approach (gotten from Drupal configuration):
set handler to native_file (i'd use PDOSessionHanlder, but seems it's not very stable);
create a seesions directory under app folder;
config.yml file:
session:
handler_id: session.handler.native_file
cookie_domain: %cookie_domain%
name: SFSESSID
cookie_lifetime: 2000000 # change this if you want
save_path: "%kernel.root_dir%/sessions"
gc_divisor: 100
gc_maxlifetime: 200000 # change this if you want
gc_probability: 1