Database |> Language |> Keywords |> 

SET

Contents

Definition

When you want to update the session corresponding to the browser used to evaluate an LSD SQL trip, the SET keyword can be helpful whether you’re looking to set a cookie or key-value pair in localStorage.

|> SET <target> <name> <value>

When you want to SET a name or value that contains a space, either use a variable or surround the value with single/double quotes; the same mark must be used at the start and end of the space-containing string.

|> SET <target> "a name with a space" 'value that has a space'

To set a COOKIE, provide the name and value you’d like to set it to.

|> SET COOKIE cookie_name cookie_value

localStorage

To update the LOCALSTORAGE, provide the key and value you’d like to set.

|> SET LOCALSTORAGE some_key some_value

Example

At the top of our example page is text that reads “Click to see the [snickerdoodle] cookie” and, as you can imagine, setting the snickerdoodle cookie string then clicking on the button labeled UPDATE should present whatever we set the cookie value to.

Let’s start by beginning on the website of interest.

example_page <| https://lsd.so/example |

FROM example_page

Next, let’s set the snickerdoodle cookie.

example_page <| https://lsd.so/example |
cookie_name <| "snickerdoodle" |
cookie_value <| "What a long strange LSD SQL trip it's been" |

FROM example_page
|> SET COOKIE cookie_name cookie_value

Following the content on the page, then click on the button with id cookie-string-button.

example_page <| https://lsd.so/example |
cookie_name <| "snickerdoodle" |
cookie_value <| "What a long strange LSD SQL trip it's been" |
update_button <| button#cookie-string-button |

FROM example_page
|> SET COOKIE cookie_name cookie_value
|> CLICK ON update_button

Lastly, let’s grab what’s being displayed as the snickerdoodle cookie value to confirm we set the cookie as expected.

example_page <| https://lsd.so/example |
cookie_name <| "snickerdoodle" |
cookie_value <| "What a long strange LSD SQL trip it's been" |
update_button <| button#cookie-string-button |
snickerdoodle <| h2#cookie-string |

FROM example_page
|> SET COOKIE cookie_name cookie_value
|> CLICK ON update_button
|> SELECT snickerdoodle

Related: