Using Session Variables


Session variables allow you store values that will persist across the life of a scraping session.

Setting session variables

There are a few different ways to set session variables.

  1. Within a script using the setVariable method of the session object
  2. Designate that the value matched by a extractor token should be saved in a session variable (check Save in session variable in the main tab of the extractor token).
  3. Using the RemoteScrapingSession object from external sources (such as a PHP or ASP script) via their setVariable methods (see scripting in screen-scraper for more details).

Retrieving values from session variables

As with setting session variables, there is more than one way to retrieve values of session variables.

  1. Within a script using the getVariable method of the session object.
  2. Embed the identifier for the session variable, surrounded by ~# and #~ delimiters.

    If you have a session variable identified by QUERY_PARAM you might embed it into the URL field of a scrapeable file using screen-scraper will automatically replace the ~#QUERY_PARAM#~ with the value of the session variable.