evercookie | evercookie gem for Ruby on Rails | Application Framework library
kandi X-RAY | evercookie Summary
kandi X-RAY | evercookie Summary
evercookie gem for Ruby on Rails
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of evercookie
evercookie Key Features
evercookie Examples and Code Snippets
Community Discussions
Trending Discussions on evercookie
QUESTION
What I want is to compare current url with my cookie array which would contain all the URL's a user has visited so it would compare that whether the array contains the current link or not so if not it would push that new link to the array and would again recreate the cookie with the new array which would contain the new pushed link so what I am facing right now is that everytime the if function which checks for the unique link always comes true I am not sure that what's the problem?
Can you people please have a look over it :
...ANSWER
Answered 2017-Jul-05 at 19:23The logic is not correct. If you want to add a value to an array only if it doesn't exist yet, you have to check all elements before you add it.
In your code you are adding the value as soon as any of the element doesn't match. That will always be the case of course because out n
elements, n - 1
will not match.
One way to do it would be to use Array#every
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install evercookie
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page