Jump to content
php.lv forumi

sesijas nedarbojas


cilveks

Recommended Posts

index.php pashaa lapas saakumaa ir

<?php session_start(); ?>

un taalaak kodaa

$sel_user = mysql_query("SELECT * FROM users WHERE user_id='$vards' AND pass='$parole'");
if (mysql_num_rows($sel_user) == 0) {
	echo "nekaa!";
	}
	else {
		$_SESSION['loged_in'] = $vards;
		header('Location: lapa.php');
		}

lapa.php

<?php 
session_start( );
if (!isset($_SESSION['loged_in']))
{
header('Location: index.php');
}
?>

Ievadot pareizi paroli un usernami vinjsh visu laiku redirektee uz index.php, bez sessijaam viss darbojas kaa vajag.

Edited by cilveks
Link to comment
Share on other sites

Pirmiit meegjinaaju jau otraa lapaa ar echo $_SESSION['loged_in']; un nekaads parametrs netiek nodots(undefined variable loged_in), taapeec ar saku, ka sesijas nedarbojas.

print_r($_SESSIONS); Notice: Undefined variable: _SESSIONS in ..lapa.php on line 9

Pirmajaa lapaa viss darbojas kaa naakas, sesijas mainiigo atpaziist(Array ( [loged_in] => janis ) ),bet koliidz redirektee, taa sesija nedarbojas.

Link to comment
Share on other sites

print_r($_SESSIONS); ?

Mana kljuda. Kodaa ir pareizi, $_SESSION.

 

php.ini defaulto negribu likt, jo ir vairaakas opcijas kuras esmu mainiijis, lai piedabutu straadaat PHP+mysql. Defaultais konfigs nestraadaa prieksh manis. Un php.ini sadaljaa par sessions ir defaultais konfigs.

phpinfo()

session
Session Support 	enabled
Registered save handlers 	files user
Registered serializer handlers 	php php_binary wddx

Directive	Local Value	Master Value
session.auto_start	Off	Off
session.bug_compat_42	Off	Off
session.bug_compat_warn	On	On
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	no value	no value
session.cookie_lifetime	0	0
session.cookie_path	/	/
session.cookie_secure	Off	Off
session.entropy_file	no value	no value
session.entropy_length	0	0
session.gc_divisor	1000	1000
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.hash_bits_per_character	5	5
session.hash_function	0	0
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	no value	no value
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	0	0

Link to comment
Share on other sites

Atrisinaats!

 

pamainiiju shos parametrus, nezinu kursh bija likteniigais, bet galvenais ka darbojas sesijas.

session.bug_compat_42 On

session.gc_divisor 100

session.hash_bits_per_character 4

session.use_trans_sid 0

Link to comment
Share on other sites

×
×
  • Create New...