-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
could device_view functionality be optionally session based? #5
Comments
You offer good ideas, but the next month I will have very little time. You can do PR's or I can add you to the list of collaborators. Together productively! |
Yeah. I have bit similar situation ongoing but I shall make PR's in the future if I have time. |
This feature wasn't included in my PR and is still in todo list. |
Ok |
Is this going to be added? This is an issue I had as well where the cookie kept the user on the full version and they'd have to manually switch back. My work around for now is: if ($mobile_detector->isMobile()) {
$response = new Response;
$response->headers->clearCookie(DeviceView::COOKIE_KEY);
$response->send();
} In the controller, might not be the best way but session based would definately be good! |
Currently I don't have any need for this feature so I think nobody is working on it. |
I also need this feature. Can't you guys just solve it with Cookie Lifetime? Now we have 30 days, just change it to expire=0 and we're all set? |
I think we'd need a way to get back to the mobile view (or in other words: to the default device behaviour), regardless of cookie lifetime or whether the view overwriting is attached to the session. I found another workaround that seems to work: I included the following at the very bottom of my "desktop" template:
Thanks to the is_mobile() check, this will only ever be displayed if a mobile device displays the full version (which only happens when the view is overridden). Applying this trick in your mobile template could also be helpful to give accidental desktop visitors a chance of reaching the corresponding full desktop page (though #43 would be nice, too :)). |
Creating a `new Cookie()` in SF4.2 triggers a deprecation notice, causing test suites to fail. The deprecation notice relates to the default value of two of the cookie constructor arguments. The notice suggests using the `Cookie::create()` method, but this is not available in Symfony versions older than 4.2. The alternative is to explicitly set values for all constructor arguments. This allows compatibility with older versions of Symfony while also supporting the newer versions in future. ``` The default value of the "$secure" and "$samesite" arguments of "Symfony\Component\HttpFoundation\Cookie::__construct"'s constructor will respectively change from "false" to "null" and from "null" to "lax" in Symfony 5.0, you should define their values explicitly or use "Cookie::create()" instead. Stack trace: #0 vendor/sentry/sentry/lib/Raven/ErrorHandler.php(127): Raven_Breadcrumbs_ErrorHandler->handleError(16384, 'The default val...', '/var/www/vendor...', 91, Array) suncat2000#1 [internal function]: Raven_ErrorHandler->handleError(16384, 'The default val...', '/var/www/vendor...', 91, Array) suncat2000#2 vendor/symfony/http-foundation/Cookie.php(91): trigger_error('The default val...', 16384) suncat2000#3 vendor/suncat/mobile-detect-bundle/SunCat/MobileDetectBundle/Helper/DeviceView.php(476): Symfony\Component\HttpFoundation\Cookie->__construct('device_view', 'full', Object(DateTime), '/', '', false, true) suncat2000#4 vendor/suncat/mobile-detect-bundle/SunCat/MobileDetectBundle/Helper/DeviceView.php(299): SunCat\MobileDetectBundle\Helper\DeviceView->createCookie('full') suncat2000#5 vendor/suncat/mobile-detect-bundle/SunCat/MobileDetectBundle/EventListener/RequestResponseListener.php(219): SunCat\MobileDetectBundle\Helper\DeviceView->modifyResponse('full', Object(Symfony\Component\HttpFoundation\Response)) suncat2000#6 vendor/suncat/mobile-detect-bundle/SunCat/MobileDetectBundle/EventListener/RequestResponseListener.php(177): SunCat\MobileDetectBundle\EventListener\RequestResponseListener->SunCat\MobileDetectBundle\EventListener\{closure}(Object(SunCat\MobileDetectBundle\Helper\DeviceView), Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent)) suncat2000#7 vendor/symfony/event-dispatcher/EventDispatcher.php(212): SunCat\MobileDetectBundle\EventListener\RequestResponseListener->handleResponse(Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent), 'kernel.response', Object(Symfony\Component\EventDispatcher\EventDispatcher)) suncat2000#8 vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.response', Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent)) suncat2000#9 vendor/symfony/http-kernel/HttpKernel.php(189): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.response', Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent)) suncat2000#10 vendor/symfony/http-kernel/HttpKernel.php(171): Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object(Symfony\Component\HttpFoundation\Response), Object(Symfony\Component\HttpFoundation\Request), 1) suncat2000#11 vendor/symfony/http-kernel/HttpKernel.php(67): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) suncat2000#12 vendor/symfony/http-kernel/Kernel.php(198): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) suncat2000#13 vendor/symfony/http-kernel/Client.php(68): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) suncat2000#14 vendor/symfony/framework-bundle/Client.php(131): Symfony\Component\HttpKernel\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request)) suncat2000#15 vendor/symfony/browser-kit/Client.php(405): Symfony\Bundle\FrameworkBundle\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request)) suncat2000#16 tests/functional/Bundle/QuizBundle/Controller/PublicControllerTest.php(13): Symfony\Component\BrowserKit\Client->request('GET', 'http://localhos...') suncat2000#17 [internal function]: Weirdly\Bundle\QuizBundle\Controller\PublicControllerTest->testPublicQuiz() suncat2000#18 {main} Exited with code 1 ``` This pull request introduces those arguments and sets them explicitly, maintaining current behaviour with no backwards-breaking changes.
Current problem is that when user visit the sit with mobile and he decides to check full page version he is stuck with full page version unless he manually switches back.
I think that it would be logical to always redirect new mobile sessions to mobile page.
The text was updated successfully, but these errors were encountered: