sessions misbehaving

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
burzvingion
Forum Newbie
Posts: 11
Joined: Sun Apr 18, 2004 2:30 pm

sessions misbehaving

Post by burzvingion »

I am having trouble with session support, the first time you access a page from my site, it tries to pass the session id through GET, and any subsesqent requests php uses cookies. I want it to always use cookies, so I set 'session.use_only_cookies' (i believe thats what its called...) in a .htaccess file, and phpinfo shows that it's been changed, but it still doesnt cooperate.
Look at the links: http://www.existential-theory.ssxh.net/index.php
phpinfo(): http://www.existential-theory.ssxh.net/ ... on=phpinfo

(The site is still very much under construction)

[edit] Solved the problem, not really but a workaround. If its the first visit, php sends a Location header with the same URI and GET query

Code: Select all

$reloadpage = false;
if(!isset($_SESSION['last_page'])) $reloadpage = true;

//Set the last page session var to the absolute location of this page.
$_SESSION['last_page'] = $url['page_abs'];

if($reloadpage)
{
	$query = '';
	if($url['query'] != '') $query = '?' . $url['query'];
	header('Location: ' . $url['page_abs'] . $query); die();
	unset($query);
}
unset($reloadpage);
Post Reply