Jump to content
Larry Ullman's Book Forums

Recommended Posts

So I have gone through Chapter 12 a few times. This chapter shows you how to make a login functions first using cookies and then using sessions. I have no problem with creating the login functions with the cookies method using the provided scripts with this book. However when I get to the Session section the provided scripts do not work for me. When I get to Script 12.9 things stop working for example After logging in, I am supposed to be redirected to loggedin.php, which will welcome the user by name using the stored session value. It does not happen for me.

 

Here is my cookies website that works with books files

 

http://www.trueacewebdesign.com/larry-php/website-login-w-cookies/index.php

 

Here is the session files website with the books files that does not work

 

http://www.trueacewebdesign.com/larry-php/website-login-w-sessions/index.php

 

Here is the a zip file of all the session files that has everything in place.

 

http://www.trueacewebdesign.com/website-login-w-sessions.zip

 

 

I am still a newbie to PHP. However from my understanding I do not need to turn on any special configuration for sessions to work. Note I have successfully used sessions on the same host last month form a different book so I know its not my configuration. 

 

Did I miss a step in the book? I don’t see how that is possible since I am using the files unedited from the book.

 

Thank you

 

JP

Link to comment
Share on other sites

I can't find anything obvious wrong.

 

In your login.php, what argument is inside the redirect_user() function.

At the moment, you are being redirected to index.php. This is the default setting for the redirect_user() function.

What you need to have is redirect_user('loggedin.php')

Can you confirm what code you have running on the server for redirect_user()?

Link to comment
Share on other sites

I have narrowed the issue down to the webhost. I have uploaded all the files to Godaddy Hosting and the Login form works now.

 

So the issue has to do with Fatcow hosting. I will update this post after I find out what needs to be done on the Fatcow hosting side. In the meantime I have checked the sessions section in the php info file on fatcow. here is what i got.

session

Link to comment
Share on other sites

There's nothing obviously there that's causing the problem. It could just be an issue with switching from one type of authentication (cookies) to another (session) from the same host (like a caching issue). In short, unless you see issues with maintaining sessions again in the future, I wouldn't worry about it.

Link to comment
Share on other sites

Hi Larry,

 

I thought I read in your book that for sessions I may need to state the path to the folder

 

session.save_path

 

it looks like I have /var/phpsessions as a savepath. If you look at my php infor screenshot.

 

Just to confirm I dont need to add anything about that to the book php files provided for session scripting?

Link to comment
Share on other sites

Solved!!!! :D

I had to add a savepath before my session. I added the following code to the login.php and loggedin.php scripts

 

 

session_save_path("/home/users/web/b2529/moo.trueace/cgi-bin/tmp");
session_start(); // Start the session.

 

So the bottom line is make sure to check your hosting config if you have session issues.

 

JP

Link to comment
Share on other sites

 Share

×
×
  • Create New...