Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

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!

Igor
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1675
Total Polls:
6
Total Posts:
5917
Total Posts Today:
1
User Info:
 
Total Users:
11559
Newest User:
pitbull911
Members Online:
2
Guests Online:
257


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked