can you really set a session var from apache?

i am talking about i've

<VirtualHost *:80>
ServerName www.domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain/
</VirtualHost>

pointing towards the primary site after which i'd like for that customers who open a sub domain like en.domain.com, to load the word what file EN and so forth..

<VirtualHost *:80>
ServerName en.domain.com
ServerAlias en.domain.com
DocumentRoot /var/www/domain/ [????]
</VirtualHost>

how do i pass any var out of this config file? or how do i place it? other solutions? thanks!

You could utilize SetEnv in apache and getenv in php. Which will pass a flexible from Apache into PHP, but setting it within the $_SESSION is pointless because the value from apache is kinda static.

// in apache
SetEnv VARNAME myvalue

// in php
echo getenv('VARNAME');

$_SERVER["HTTP_HOST"] would show this but $_SERVER["HTTP_ACCEPT_LANGUAGE"] may well be a better candidate for the problem at hands.

You are able to set an environment variable which could then be utilized by PHP. The vhost config would look something similar to this:

SetEnv UNIQUE_ENV_VAR_NAME yourValue

then in PHP

if (isset($_SERVER['UNIQUE_ENV_VAR_NAME'])) {
    executeYourCode();
}

You should use mod_env to create atmosphere variables inside your config:

<VirtualHost *:80>
  ServerName en.domain.com
  ServerAlias en.domain.com
  DocumentRoot /var/www/domain/
  SetEnv LANG en
</VirtualHost>

You'll be able to get them from PHP:

$lang = getenv('LANG');

As others have previously clarified, mod_env is definitely an answer. Another possibility is applying mod_rewrite and you will have the ability to mix a lot of your virtual hosts.... for instance:

RewriteEngine On
RewriteCond %{SERVER_NAME} ^([^.]*)\.domain\.com$
RewriteRule ^.*$(subdomain)? - [E=SUBDOMAIN:%1]