You can use this in your shell dotfile (e.g. ~/.bash_profile, ~/.zshrc) to create a screen session when you log in or reattach to an existing screen:
if [[ $TERM != 'screen' ]] ; then
if [[ `screen -list | grep -v "No" | awk '$2 { print }' | wc -l` == 0 ]] ; then
screen
else
screen -dr
fi
fi
This works in bash and zsh.
attachbash_profilebootconfigurationscreenscreenrcsessionshellstartup
Beware that on some versions of PHP, the PHP session ID value is a hexadecimal hash but on some newer systems the configuration is used to adjust the contents of the session ID string:
; Define how many bits are stored in each character when converting ; the binary hash data to something readable. ; ; 4 bits: 0-9, a-f ; 5 bits: 0-9, a-v ; 6 bits: 0-9, a-z, A-Z, "-", "," session.hash_bits_per_character = 5
configurationgotchahexadecimallanguagesphpphp.iniprogrammingsession
When using sessions in PHP, the default PHP configuration causes PHP to send a no-cache header to your browser so that session-managed pages are not cached. Sometimes this is not the desired behavior, such as when writing a script whose output is binary data such as images which are stored in a database. If this is the case, you can turn off the caching by using functions to modify the PHP configuration on a per-request basis. Call these functions before calling the session_start() function:
// Let the browser and proxies cache output
session_cache_limiter('public');
// One-day (60 * 24, in minutes) cache expiration time for output
session_cache_expire(60 * 24);
(Note: this behavior is documented at http://www.php.net/manual/en/ref.session.php.)
functionsheadershttplanguagesphpprogrammingsession