Login Session avatar
Login Session
Try for free

No credit card required

View all Actors
Login Session

Login Session

pocesar/login-session
Try for free

No credit card required

Get localStorage, sessionStorage and cookies from logins for usage in other actors.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "userAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36",
11    "maxRequestRetries": 0,
12    "sessionConfig": {
13        "storageName": "login-sessions",
14        "maxAgeSecs": 3600,
15        "maxUsageCount": 100,
16        "maxPoolSize": 100
17    },
18    "steps": [
19        {
20            "username": {
21                "selector": "input#email"
22            },
23            "password": {
24                "selector": "input#pass"
25            },
26            "submit": {
27                "selector": "input[type=\"submit\"]"
28            },
29            "failed": {
30                "selector": "[role=\"alert\"]"
31            },
32            "waitForMillis": 5000
33        }
34    ],
35    "cookieDomains": [],
36    "gotoTimeout": 30,
37    "proxyConfiguration": {
38        "useApifyProxy": true
39    },
40    "extraUrlPatterns": []
41};
42
43(async () => {
44    // Run the Actor and wait for it to finish
45    const run = await client.actor("pocesar/login-session").call(input);
46
47    // Fetch and print Actor results from the run's dataset (if any)
48    console.log('Results from dataset');
49    console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
50    const { items } = await client.dataset(run.defaultDatasetId).listItems();
51    items.forEach((item) => {
52        console.dir(item);
53    });
54})();
55
56// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community
Actor metrics
  • 7 monthly users
  • 4 stars
  • 8.3% runs succeeded
  • Created in Feb 2020
  • Modified about 3 years ago
Categories