Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itemconsulting/lib-xp-session
Library for storing attributes on the Enonic session
https://github.com/itemconsulting/lib-xp-session
enonic-xp session
Last synced: 14 days ago
JSON representation
Library for storing attributes on the Enonic session
- Host: GitHub
- URL: https://github.com/itemconsulting/lib-xp-session
- Owner: ItemConsulting
- License: mit
- Created: 2019-10-04T09:14:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-14T15:59:54.000Z (almost 2 years ago)
- Last Synced: 2024-11-12T07:16:14.555Z (2 months ago)
- Topics: enonic-xp, session
- Language: JavaScript
- Homepage:
- Size: 470 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Enonic Session Library
Enonic XP Library for storing attributes on a users session.
[![](https://jitpack.io/v/no.item/lib-xp-session.svg)](https://jitpack.io/#no.item/lib-xp-session)
## Warning
> **Warning**
> This library will **not work in clustered environments** with multiple instances of XP running, since the state of the user is not replicated.You can instead use cookies to store attributes related to the user.
## Installation
To install this library you need to add a new dependency to your app's build.gradle file.
### Gradle
```groovy
repositories {
maven { url 'https://jitpack.io' }
}dependencies {
include 'no.item:lib-xp-session:1.0.0'
}
```## Usage
After updating the gradle file, you can import the `/lib/session` library.
The library includes the following functions:
* `setAttribute(key, value)`
* `getAttribute(key)`
* `removeAttribute(key)`
* `getAttributeNames()`
* `getId()`
* `getCreationTime()`### Controllers
```javascript
var sessionLib = require('/lib/session');exports.get = function() {
sessionLib.setAttribute("myKey", "myValue");var myValue = sessionLib.getAttribute("myKey"); // "myValue" is returned
...
}
```## Deploying
### Building
To build he project run the following code
```bash
./gradlew build
```### Deploy locally
Deploy locally for testing purposes:
```bash
./gradlew publishToMavenLocal
```## Deploy to Jitpack
Go to the [Jitpack page for lib-xp-session](https://jitpack.io/#no.item/lib-xp-session) to deploy from Github.