Nice plug in…just what I need. As others have pointed out, I’m also wondering about the outstanding issue with the extra underscore being added to the beginning of the cookie name (it only happens when using method=”script” to set it). For me, it makes no difference if I set the “cookie prefix” to “exp_” in the CP -> Admin -> Cookie settings. Have there been any updates to this?
thanks slaphotw. I was hoping not to do that because if it gets enhancements in the future (sans the double underscore), I’ll end up overwriting it and probably forget about it until I realize my code’s not working 😊
Another thing I noticed is that when setting the cookie via the script method, it sets the host at www.example.com instead of .example.com (to include all subdomains) like the default php method works. Probably not a big deal for most though.
Thanks again 😊
Thanks Laisvunas for all your help… even for add-ons you create without cost… you still support them. That’s crazy and kind at the same time! How do you do it?
I’m having an issue I can’t put my finger on.
I want to give people a view option on mobile devices. I’m using the Mobile Detect plugin which is working nicely. In order to give them a choice… I check for a cookie that is set by the choice template… if that cookie doesn’t exist… I want to automatically forward them to the choice template and at that point they can choose between mobile or regular view. The regular view would take them back to the normal index template which will check for the cookie and if it exists… it will not forward them. That’s the idea at least… although I haven’t got it to work correctly yet.
I’m trying something like this…
{exp:cookie_plus:get name="mobilechoicecookie"}
{if cookie!="decided"}
{exp:mobile_detect location="http://www.website.com/site/mobile_view_choice/"}
{/if}
{/exp:cookie_plus:get}
However, it doesn’t seem to obey the if statement. It always forwards it when viewing with a mobile device.
Please note: On the mobile template I am setting a cookie like this…
{exp:cookie_plus:set name="mobilechoicecookie" value="decided" seconds="3600"}
That way when a person chooses to view the site normally and they go back to the regular index page where the code checks for the cookie… they shouldn’t be forwarded to the view option again.
I also tried this…
{exp:cookie_plus:get name="mobilechoicecookie"}
{if cookie=="decided"}
<!-- nothing happens -->
{if:else}
{exp:mobile_detect location="http://www.website.com/site/mobile_view_choice/"}
{/if}
{/exp:cookie_plus:get}
Yet, it still forwards the view to the mobile template.
What am I missing here?
What am I missing here?
The first thing to check is try adding the underscore before the cookie name (see above) since there’s an extra underscore in the code that hasn’t been updated yet.
So try:
{exp:cookie_plus:get name="_mobilechoicecookie"}
Thanks Kyle.
That didn’t work but I did decide to go in an modify the original plugin to remove the double underscores. That didn’t fix it either.
I’m now just testing to see if I can get it to set the cookie. So far, I have not been successful and have tried several code examples. I’m not sure what I’m missing here. Anybody else have any ideas?
In one template, I’m setting the cookie this way…
{exp:cookie_plus:set name="mobilechoicecookie" value="decided" seconds="3600"}
In another template, I’m checking for the cookie like this…
{exp:cookie_plus:get name="mobilechoicecookie"}
{if cookie=="decided"}
<!-- decided cookie is set -->
{if:else}
<!-- decided cookie is NOT set -->
{/if}
{/exp:cookie_plus:get}
Everytime I check the source code… it tells me decided cookie is NOT set. Ideas?
I might add that I’m using MSM and the site I’m using is not the main site where all the system files are installed. I don’t know if that matters or not.
Thanks Kyle. That didn’t work but I did decide to go in an modify the original plugin to remove the double underscores. That didn’t fix it either. I’m now just testing to see if I can get it to set the cookie. So far, I have not been successful and have tried several code examples. I’m not sure what I’m missing here. Anybody else have any ideas? In one template, I’m setting the cookie this way…In another template, I’m checking for the cookie like this…{exp:cookie_plus:set name="mobilechoicecookie" value="decided" seconds="3600"}
Everytime I check the source code… it tells me decided cookie is NOT set. Ideas? I might add that I’m using MSM and the site I’m using is not the main site where all the system files are installed. I don’t know if that matters or not.{exp:cookie_plus:get name="mobilechoicecookie"} {if cookie=="decided"} <!-- decided cookie is set --> {if:else} <!-- decided cookie is NOT set --> {/if} {/exp:cookie_plus:get}
If you have the ability to browse cookies for the site, I know Safari and Firefox have something for that, you can at least see if the cookie is being set in the first place. That’ll give you a starting point. If you see it set, try to output the value and see if that works. Make sure you added the method=”script” parameter if you’re not placing the set code at the top of the page.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.