# cookieToInitialState | @account-kit/core

> Overview of the cookieToInitialState function from @account-kit/core

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

```ts
function cookieToInitialState(config, cookie?): undefined | StoredState;
```

Defined in: [account-kit/core/src/utils/cookies.ts:77](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/core/src/utils/cookies.ts#L77)

Converts a cookie into an initial state object

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `config`
      </td>

      <td>
        [`AlchemyAccountsConfig`](../type-aliases/AlchemyAccountsConfig)
      </td>

      <td>
        the account config containing the client store
      </td>
    </tr>

    <tr>
      <td>
        `cookie?`
      </td>

      <td>
        `string`
      </td>

      <td>
        optional cookie string
      </td>
    </tr>

  </tbody>
</table>

## Returns

`undefined` | [`StoredState`](../type-aliases/StoredState)

the deserialized AlchemyClientState if the cookie exists, otherwise undefined