Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session and/or cookie problem

Status
Not open for further replies.

Zych

IS-IT--Management
Apr 3, 2003
313
US
Hello Everybody,

I have setup a simpe site that verifies a user and redirects them where they need to go. For the last page I want to setup a session or cookie variable to make sure they have been verified. The session part worked fine on a local server I have. I then uploaded it to my hosting company and it fails. If I try to echo the session variable it blanks the whole page.

I then decided to try cookies. Apparently I do not know how to do this. I used the following to set the cookie: setcookie("grpchk", True, time()+2); then I redirected page with a header() statement.

The time is set low so I can test it out. I have the following on the redirected page: <?php echo $_COOKIE["grpchk"] ?>
This returns a error: Notice: Undefined index: grpchk in C:\ftproot\ on line 99

So I guess my questions are the following:

How can I test to see if sessions are supported on a server?

What is wrong with my cookie implementation?

Thanks.
 
The problem with your setcookie() invocation may be that you're setting the cookie to expire in two seconds.

Also, on what web server are you running PHP? IIS, for example, was built around a unique interpretation of the HTTP spec which does not allow cookies to be set in the same transaction that a "Location" header is set.


Your problem with session variables on the hosted server may be that your script is producing an error which is not being displayed. Is the ISP logging PHP errors in a file you can examine?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks sleipnir214. I tried to up it to 50 to see what would happen and I got the same error.

My internal system is a XP system running Apache. The remote system is a Linux system running Apache. The host is registerfly.com

- Zych
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top