---
name: "System.getEnv"
section: "3kaya"
platform: "linux"
package: "kaya"
version: "0.4.4-6.2"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/System.getEnv"
---

# System.getEnv(3kaya)

Get the value of an environment variable.

## NAME

System::getEnv - Get the value of an environment variable.

## SYNOPSIS

**String getEnv(** *String env* **)**

## ARGUMENTS

**env** The name of the environment variable

## DESCRIPTION

Retrieves the value of an environment variable.

This is often necessary in a web application as the web server will set environment variables in the program. Some of these headers are set by the server environment, others are set based on the current request (and so may be trivially forged by the user's browser).

-

   ua = getEnv("HTTP\_USER\_AGENT"); // Contents of User-Agent header\
    host = getEnv("HTTP\_HOST"); // the IP address of the web server\
    user = getEnv("REMOTE\_USER"); // the username under HTTP authentication\
    ip = getEnv("REMOTE\_ADDR"); // the client's IP address

Environment variables are also useful for command-line programs

-

   home = getEnv("HOME"); // The user's home directory on Posix systems\
    proxy = getEnv("HTTP\_PROXY"); // The HTTP proxy to use for outgoing connections

If the environment variable is not set, the empty String will be returned.

## AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

## LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.

## RELATED

**System.getArgs (3kaya)**

**System.getPID (3kaya)**
