We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Cookie Plus

Development and Programming

smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill

Looks like there’s an extra underscore being added to the beginning of the cookie name in v1.2 so when you use the “get” tags it won’t work without adding the underscore before the cookie name.

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
15 years ago
Nathan Pitman's avatar Nathan Pitman

Is it possible to delete a cookie by specifying a negative value for seconds? 😊

       
goodcompany's avatar
goodcompany
51 posts
15 years ago
goodcompany's avatar goodcompany

Are there any plans to make this plug-in compatible with EE2? I love it, and rely on it for most of the sites I build.

       
susansan's avatar
susansan
75 posts
15 years ago
susansan's avatar susansan

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?

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
15 years ago
Matt Weinberg's avatar Matt Weinberg

The plugin file actually has two underscores written in the lines where the cookie name is set using the script tag. If you just do a find/replace in the plugin file, finding two underscores (__) and changing it to one (_) it should work.

       
susansan's avatar
susansan
75 posts
15 years ago
susansan's avatar susansan

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 😊

       
Todd D.'s avatar
Todd D.
460 posts
15 years ago
Todd D.'s avatar Todd D.

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?

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill
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"}
       
Todd D.'s avatar
Todd D.
460 posts
15 years ago
Todd D.'s avatar Todd D.

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.

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill
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.

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.

       
First 3 4 5

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.