angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

More powerful $cookies service

Open reichart opened this issue 14 years ago • 67 comments

I want to set a cookie on the root path / so it's available everywhere on the domain.

But the $cookies service only accepts name and value, and always sets the cookie path to the current page via self.baseHref().

Could the $cookies service be extended to provide access to additional cookie properties like path, expires, domain and secure?

I quite like the API of the jquery.cookie plugin: https://github.com/carhartl/jquery-cookie#usage. It keeps the common name=value use case simple and allows to set additional cookie properties via a third options object parameter.

I'm not very proficient in Javascript but I might try to implement something over the weekend.

reichart avatar May 11 '12 11:05 reichart

:+1: , but a 2 year old outstanding issue with this many bumps? Probably best to find another solution.

joseym avatar Apr 24 '14 19:04 joseym

@joseym I can imagine most people found a workaround 'till now. This issues is in the Backlog milestone, which implies it would get 'fixed' sometime in the future.

** Later edit: ** PR would be helpful, albeit I don't need this now. Been using https://github.com/grevory/angular-local-storage with great success.

kmlx avatar Apr 24 '14 19:04 kmlx

+1

yokomizor avatar Apr 28 '14 20:04 yokomizor

+1.

Doesn't make much sense to have cookies, then to skip every single feature of them.

ghost avatar May 14 '14 19:05 ghost

+1

HouCoder avatar May 16 '14 06:05 HouCoder

:+1:

akarelas avatar May 21 '14 07:05 akarelas

+1 ... Can't believe this cookie API is this poor edit: just found https://github.com/ivpusic/angular-cookie

jscti avatar May 23 '14 15:05 jscti

@bixibu I ended up using the same library and it works well.

Some have alluded to the existence of other libraries as the solution, however I believe (as I think most others do as well) that if angular is going to have its own cookie module, it should be complete, or not exist at all.

Most on-boarders would assume that the cookie module that comes from the creators of the framework they're using would be the best option.

Its simply misleading.

joseym avatar May 23 '14 16:05 joseym

:+1: No reason to not have the options

ItsBenCodes avatar May 26 '14 12:05 ItsBenCodes

+1

huyinghuan avatar May 27 '14 01:05 huyinghuan

+1

Soviut avatar Jun 04 '14 17:06 Soviut

+1

GinoF avatar Jun 04 '14 18:06 GinoF

+1

dhruv avatar Jun 13 '14 01:06 dhruv

Also +1. Seriously.

elsewares avatar Jun 23 '14 18:06 elsewares

+1

danielcamargo avatar Jul 03 '14 22:07 danielcamargo

+1 - at least allow for setting path

Meligy avatar Jul 07 '14 01:07 Meligy

+1 I actually didn't believe the docs to be accurate on this... but they are

michi88 avatar Jul 22 '14 19:07 michi88

one more for the pile: :+1:

tthew avatar Jul 23 '14 12:07 tthew

I would have started work on this but this seems to be already be addressed by pull requests #6335 submitted in February and a sequel #6507 in March. Which sadly havent been merged...

madumlao avatar Aug 02 '14 09:08 madumlao

one more +1

adrianstainforth avatar Aug 07 '14 18:08 adrianstainforth