Url

Pre-Navigation Storage Actions

WithStorageType begins a storage action configuration - set the type (cookie, localStorage, sessionStorage, indexedDb, cache). WithStorageKey sets the key for the storage item. WithStorageData sets the value to write for set operations. WithStoragePath and WithStorageDomain restrict cookie scope. WithStorageStoreName sets the IndexedDB store name. WithDeleteAcrossOrigins controls whether delete operations cross origin boundaries. WithUserDefined stores arbitrary metadata for GPAL-internal filtering. Multiple storage actions can be chained on a single GPALUrl.

Examples

GPAL Fluent: High-level fluent C# API

//Storage actions on a GPALUrl execute immediately before the navigation - GPAL runs the storage operation, then navigates to the URL. This is the clean way to set up browser state before visiting a page.

// Read a cookie before navigating

var checkUrl = GPAL.Url

.ForUrl("https://example.com")

.WithStorageType(WebsiteStorageType.cookie)

.WithStorageDomain("example.com")

.WithStorageKey("session_id")

.RunGet(WebsiteStorageType.cookie);


GPAL.Browser.GoTo(checkUrl);


// Set a localStorage value before navigating

var themedUrl = GPAL.Url

.ForUrl("https://app.example.com")

.WithStorageType(WebsiteStorageType.localStorage)

.WithStorageKey("theme")

.WithStorageData("dark")

.RunSet(WebsiteStorageType.localStorage);


GPAL.Browser.GoTo(themedUrl);


// Clear cookies before navigating

var cleanUrl = GPAL.Url

.ForUrl("https://example.com")

.WithStorageType(WebsiteStorageType.cookie)

.WithDeleteAcrossOrigins(true)

.RunDelete(WebsiteStorageType.cookie);


GPAL.Browser.GoTo(cleanUrl);

💬 Ask GPAL