View Full Version : PHP session_start() ???


DZINE
07-02-2005, 07:33 AM
This code works on my local host but when I put it on my live site I get my error message. What can I do to prevent this?

This is the code

<?php
session_start();

//check to see if user has logged in with a valid password
if ($_SESSION['authuser'] != 1) {
echo "Sorry, but you don't have permission to view this page!";
exit();
}
?>

I login fine and go to my CMS list, but when I want to go to the adduser page It will not let me and says I am not allowed. But it works fine on my localhost at home.

crodream
07-02-2005, 11:14 AM
can you give error?

DZINE
07-02-2005, 11:19 AM
It Prints My error Even though I have logged in --echo "Sorry, but you don't have permission to view this page!";--

It does not do this on my localhost, it works fine on localhost. when I try it on the site I am using it for I can login and go to the list page but when I try to go to my add contact page it tells me I echo "Sorry, but you don't have permission to view this page!";

Is it a cookie thing and if it is what do I do?

DZINE
07-02-2005, 01:18 PM
Can someone please help?
:rolleyes:

SEO Aaron
07-04-2005, 01:57 PM
Do you have the session_start(); as the first line of your "adduser" page?
You could also print out the session array...
print_r($_SESSION);

It is also possible you might not have permisions on the server you are using to wherever the session is being stored you may have to define this to somewhere you have the apropriate permissions with the function:
session_save_path("path_to_session/session");

DZINE
07-06-2005, 12:06 PM
Yeh,

It works fine on another server. I am going to continue building this on the server that works for now. Still really new to php but am loving it. It is my first programming language. Alot to take in. Thnks for your help. :D

Atomical
07-09-2005, 04:21 PM
This could be a few things.. The first thing that comes to mind is that the /tmp directory does not have read/write access. Post your login script.

wozzaofrare
07-10-2005, 03:06 AM
r u sure its not a permissions problem on the server your running the script on?
if it works on localhost try it on another server as well maybe?