Session Variables in a Form Submit Function

I want to increment a session variable every time a form is submitted. This code is placed in the form submit function:

if (isset($_SESSION['inc1'])) {
	$_SESSION['inc1'] = $_SESSION['inc1'] + 1;  
else {
	$_SESSION['inc1'] = 1;

The snippet is valid php but it causes the form display page to break. Am I setting these session variables in the wrong way ? Thanks.

Drupal version: