Jump to content


Photo

Problem with Session_start(); * Solved


  • Please log in to reply
3 replies to this topic

#1 Drezard

Drezard
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 16 September 2006 - 11:57 PM

Heres the error:


Parse error: syntax error, unexpected ';' in C:\Program Files\xampp\htdocs\login_sucess.php on line 3


Heres my code:


<?php
if (isset($_SESSION['userinfo']{
session_start();
$user = $_SESSION['userinfo'];
setcookie('user', $user, time()+36000*24*365);
session_destroy();
}
?>

<head>

</head>

<body>

<?php

if (isset($_COOKIE['user'])) {
echo "Login Complete, Welcome $user";
}

if (!isset($_SESSION['userinfo'] (
?>
		
<meta http-equiv="refresh" content="0;url=login_form.php">;

<?php	
}
?>

</body>
</html>


Whats wrong with this code?

- Cheers, Daniel

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 17 September 2006 - 12:12 AM

You should always place you session_start(); before anything else. So this is what it should look like.

<?php
session_start();
if (isset($_SESSION['userinfo'])) { //this is were you missed two ))

Hope this helps,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 Drezard

Drezard
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 17 September 2006 - 12:39 AM

Forgot that rule.

Thanks, Daniel


#4 imartin

imartin
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 17 September 2006 - 02:02 AM

there may be times when Session_start(); wont be the very first bit of code, the important thing is that it comes before anything that will be printed to the file after processing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users