I have given up on this question as I suspect something corrupted my settings causing the problems and have since then created a new server. I figured finding the problem would take me more time than starting a new server and setting it up. However I'm still interested in finding out what caused this as it was running perfectly for 3 months and only started to show these symptoms over the weekend. **
===============================================================================
I'm having a bit of a beginner problem, probably because I've been working in other languages for the past months and I just can't seem to find out why this isn't working. I've made a very simple script to test it out, which goes as follows:
<?php session_start();
  print_r($_SESSION);
  if(isset($_SESSION['views'])){
      $_SESSION['views'] = $_SESSION['views']+ 1;
  }
  else{
      $_SESSION['views'] = 1;
  }
  echo "views = ". $_SESSION['views'];
  echo '<p><a href="">Refresh</a></p>';
  # for testing
  var_dump($_SESSION);
?>
What happens is that the var_dump shows that a session is created with a key of views and the value of 1. However when refreshing the page no active session is found, and the views key is set to 1 again.
Now the strange thing to me is that there is a session id created under PHPSESSID. I've tried to check if the path to store the sessions in was writable and it is. The headers returned by the page are as follows:
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public
Connection  close
Content-Encoding    gzip
Content-Length  68
Content-Type    text/html; charset=utf-8
Date    Wed, 18 Jan 2012 13:03:34 GMT
Expires Thu, 19 Nov 1981 08:52:00 GMT
Pragma  no-cache
Server  Apache
Vary    Accept-Encoding
X-UA-Compatible IE=Edge,chrome=1
And in the request header the session cookie is send as follows:
 Cookie PHPSESSID=0e1416r7pun3pamvc7cp8mjat3
I'm not sure if there is anything wrong in there. I am running this on an Amazon EC2 linux AMI.
I'll also include phpinfo():
PHP Version 5.3.6
System  Linux ip-**-**-**-** *.*.**.**-**.**.amzn1.x86_64 #1 SMP Sat Feb 19 23:42:04 UTC 2011 x86_64 
session
Session Support     enabled    
Registered save handlers    files user    
Registered serializer handlers  php php_binary wddx    
Directive   Local Value Master Value    
session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly On  Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   /var/lib/php/session    /var/lib/php/session
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    On  On
session.use_trans_sid   0   0
Any help would be greatly appreciated as I've been spending all day to solve this but can't seem to find the solution. If you need any more information, please let me know.
 
     
    