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.

 

[solved] How can i redirect for "one day" after cookie is detected?

[solved] How can i redirect for "one day" after cookie is detected?

Hi! My first post here, in the forum of this great component.

I have two rules:
- first: if a link contains "id_partner=100" redirect to menu voice "page100" ad write a cookie A
- second: for every link, if cookie A is detected, redirect to "page100"

i have to limit the duration of cookie because i want to have second rule valid only for 24h after the first action.

So, a user go to the site with the first special "referrer" and be redirected to a specific page. If the same user in the same day (24h) go the home page of my site it will be redirected always to the specific page.

I think i go to create many (7/8) redirects of this type, but i'm not so good in working with sessions/cookies.

How can i set the component in this way? Thanks!!!

simbus82
Owner at Simbus82 Web & Tech
Beginner Modder
ranks
useravatar
Offline
2 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] How can i redirect for "one day" after cookie is detected?

Hi,

If you need more than 4 redirects of this type, you can't use the 4 provided cookies (A-D) so it's a matter of a small snippet of PHP.

I'd set up your 1st pair of rules like this:

Rule 1: use the following PHP code in the conditions (not in the action) to detect the cookie:

if (@$_COOKIE['partnerid'] == 100) return true;

You might also wish to include a check for the "front page of the site", if you only want this redirect to take place if they go to the front page but still allow them to go to other pages.

At the very least you need to include a check for "all pages EXCEPT the one you are redirecting to" so that the redirect does not go into an endless loop. You could do this by URL (url NOT equal to X) or menu item (exclude menu item Y).

Then in the Succeed action, set up the redirect to the page you want them to be sent to.

Rule 2: detect id_partner=100 in the link. In the Succeed Action, do the redirect and also the following PHP in the Action section:

setcookie('partnerid','100',time()+24*60*60);


Repeat this pair of rules as many times as you need to, replacing the "100" with the appropriate partner id in each case.

Cheers,
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
3312 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] How can i redirect for "one day" after cookie is detected?

big_smile

i'm so happy! Thanks, it works very well!

Your support is GREAT! Very clear instructions!

simbus82
Owner at Simbus82 Web & Tech
Beginner Modder
ranks
useravatar
Offline
2 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10137
Newest User:
lexispoker1
Members Online:
1
Guests Online:
300

Online: 
liaskas

Forum Legend:

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