Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Redirect recepie with timed cookie
Redirect recepie with timed cookie
Redirect recepie with timed cookie
Hello,
I'm using MetaMod recipe to redirect to another page. There is timed cookie as well, so I adjust the time how often the users should get redirected.
The code of the recipe is the following:
$app = &JFactory::getApplication();
$c = JRequest::getInt('SeenIt', 0, 'cookie');
if ($c) return; /* if cookie was set, don't show anything, else... */
setcookie( 'SeenIt', 1, time()+900, '/' );
$app->redirect("http://www.redirectwebsite.com/");
Joomla version: 2.5.17
Metamod version: 3.15
The problem I am facing is that this does not work on iPhone/safari (didn't test for other mobile devices). The user sees the redirect code all the time, as if the cookie is not present.
I have two questions regarding this:
1. Is there a way this recipe to work on mobile devices as well?
2. Is there a way to EXCLUDE all mobile devices, so this code won't apply to them at all?
Thanks!
Re: Redirect recepie with timed cookie
Hi Igor,
I've just done some research on this, and tested on some different browsers:
Android browser: no problem
Safari/Mac: problem
Firefox/Mac: no problem
Safari/iOS7: problem.
Someone else complaining about it on iOS:
https://discussions.apple.com/thread/5652283?tstart=75
The issue appears to be that the 303 response is being cached, but is not supposed to be according to the standard. The cookie is in fact being set and you can see that by going to another URL on the same site, which this time does NOT redirect.
In Safari/Mac you can clear the cache, and after doing this the redirect stops taking effect. That's why I am sure it's a caching problem in Safari (or probably WebKit).
I don't know of a fix for this at this time. Perhaps there may be alternative ways to do a redirect e.g. instead of $app->redirect() above, you may have better success doing a JS redirect or meta refresh. Sorry I can't help much more there apart from pointing you in those directions to explore.
Best regards,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Redirect recepie with timed cookie
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8025
- Newest User:
- chavez1304
- Members Online:
- 1
- Guests Online:
- 113
- Online:
- chavez1304
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked