Socket
Socket
Sign inDemoInstall

ngx-cookie-service

Package Overview
Dependencies
5
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 17.0.0-rc.2 to 17.0.0-rc.3

2

package.json
{
"name": "ngx-cookie-service",
"description": "Angular cookie service",
"version": "17.0.0-rc.2",
"version": "17.0.0-rc.3",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": "Stepan Suvorov <stevermeister@gmail.com>",

@@ -66,40 +66,41 @@ # NGX Cookie Service

If you are using just standalone components, you can import the service directly into the component
```typescript
import {CookieService} from 'ngx-cookie-service';
import {Component} from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService]
})
export class HelloComponent {
constructor(private cookieService: CookieService) {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```
```typescript
import { CookieService } from 'ngx-cookie-service';
import { Component } from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService],
})
export class HelloComponent {
constructor(private cookieService: CookieService) {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```
2. You can also use `inject()` method in v14+ to inject the service into the component
```typescript
import {CookieService} from 'ngx-cookie-service';
import {Component,inject} from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService]
})
export class HelloComponent {
cookieService=inject(CookieService);
constructor() {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```
```typescript
import { CookieService } from 'ngx-cookie-service';
import { Component, inject } from '@angular/core';
@Component({
selector: 'my-component',
template: `<h1>Hello World</h1>`,
providers: [CookieService],
})
export class HelloComponent {
cookieService = inject(CookieService);
constructor() {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
}
```
## Server Side Rendering

@@ -112,9 +113,11 @@

1. Install the library using below command
```shell
npm install ngx-cookie-service-ssr --save
# or
yarn add ngx-cookie-service-ssr
```
```shell
npm install ngx-cookie-service-ssr --save
# or
yarn add ngx-cookie-service-ssr
```
2. By default, browser cookies are not

@@ -125,7 +128,7 @@ available in SSR because `document` object is not available. To overcome this, navigate to `server.ts` file in your

```typescript
server.get('*', (req, res) => {
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
});
```
```typescript
server.get('*', (req, res) => {
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
});
```

@@ -139,5 +142,5 @@ with this

providers: [
{provide: APP_BASE_HREF, useValue: req.baseUrl},
{provide: 'REQUEST', useValue: req},
{provide: 'RESPONSE', useValue: res},
{ provide: APP_BASE_HREF, useValue: req.baseUrl },
{ provide: 'REQUEST', useValue: req },
{ provide: 'RESPONSE', useValue: res },
],

@@ -163,3 +166,3 @@ });

| Angular Version | Supported Version |
|------------------------|-------------------|
| ---------------------- | ----------------- |
| 16.x.x | 16.x.x |

@@ -203,3 +206,3 @@ | 15.x.x | 15.x.x |

cookieService.set('test', 'Hello World');
cookieService.set('test', 'Hello World', {expires: 2, sameSite: 'Lax'});
cookieService.set('test', 'Hello World', { expires: 2, sameSite: 'Lax' });
```

@@ -206,0 +209,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc