Portal Home > Knowledgebase > Articles Database > PHP session is lost with paginate


PHP session is lost with paginate




Posted by acctman, 10-31-2010, 04:09 PM
this issue has never happened before when i've created/used a login session. pretty much its a basic session setup, session start, associate session variables to db results. but when the user is going through paginate pages on the site the session is lost. session start is at the top of every page. is this a server/php.ini issue?

Posted by Doh004, 10-31-2010, 08:02 PM
Have you changed the code at all? Is the session_start() not being called when doing the pagination?

Posted by speckl, 10-31-2010, 08:19 PM
Yep. I was thinking the same thing.

Posted by acctman, 10-31-2010, 09:18 PM
i'm assuming its not being called. i've added session_start() to all the pages the pagination script references and still nothing. the weird part is once logged in the user if taking to mainpage.php and then the pagination is referenced mainpage.php?page=2 or something. so its staying within the same page but background ajax script is processing it. but the session is now lost when user tries to go to any page referenced by the paginate.

Posted by speckl, 10-31-2010, 09:24 PM
You should try sticking the session_start() in the mysql db file to see if that eliminates the problem.

Posted by acctman, 11-01-2010, 12:19 AM
ok i finally found the problem. it was one of those problems where you have to really rule out everything. $pagination was looking for domain.com/mainpage.php?page=2 when it should have been www.domain.com/mainpage.php?page=2 normally that wouldn't have been a problem if this was my server/domain. I always make sure domain.com redirects to www.domain.com for all pages, if not you have problems like this. took me a week to notice that. I'm starting to learn when working on someone else system just assume its probably not setup with all the tweaks that it should have.

Posted by speckl, 11-01-2010, 12:32 AM
Now you know the reason why many scripts are setup to call the session_start() in one file only. Usually scripts have a config or header file so that is where I usually put it. Many times I will put it in the index.php file.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
SQL help needed (Views: 783)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.