Jump to content

Archived

This topic is now archived and is closed to further replies.

Drezard

Problem with Session_start(); * Solved

Recommended Posts

Heres the error:

[QUOTE]

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

[/QUOTE]

Heres my code:

[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>

[/CODE]

Whats wrong with this code?

- Cheers, Daniel

Share this post


Link to post
Share on other sites
You should always place you session_start(); before anything else. So this is what it should look like.

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

Hope this helps,
Tom

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.