Jump to content
php.lv forumi

Atkal sesijas :(


Recommended Posts

Nu uz win man sesijas gaja, bet uz Linuxa kaut ka nesanāk, itka jau viss bija uzlikt, bet nav ka vajag.

 

Sesija pieregistrejas un itkaa ir /tmp direktorijaa, bet ar php es to nevaru dabut un redzeet! Varbut uz brousera neuzliekas kukijs? Bet itka kukiji ir ieslegti!

Te phpinfo():

Session Support  enabled
Registered save handlers  files user

Directive	Local Value	Master Value
session.auto_start	Off	Off
session.bug_compat_42	On	On
session.bug_compat_warn	On	On
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	gacha.no-ip.com	gacha.no-ip.com
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	100	100
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	/tmp	/tmp
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	Off	Off

Link to comment
Share on other sites

Nu nez - es autorizacijai izmantoju sho f-ciju:

function auth($user, $pass){	

	 $pass = md5($pass . MD5);
	 $expire = time();
	 $sql = mysql_query("Select * from users where user='$user' and pass='$pass' Limit 0, 1");
	 if (!$end = mysql_num_rows($sql) == 1){header("Location: index.php?page=login&do=0"); exit();}else{
	 $_SESSION = array();
  	 session_destroy();
  	 session_start();
  	 $row = mysql_fetch_assoc($end);
  	 $_SESSION['auth'] = $row['user'];
  	 $_SESSION['expire'] = $expire;
  	 mysql_free_result($end);
  	 header("Location: index.php?page=system");
	 }

Un tad ar sho parbaudu katra lapaa:

function chek_auth(){
	 $expire = $_SESSION['expire'];
	 $time = time() - 60 * SES_TIME;
	 if (!isset($_SESSION['auth']) || $time > $expire){
	 $_SESSION = array();
  	 session_destroy();
  	 header("Location: index.php?page=login");
	 }

Nu man liekas, ka ar kodu viss ir kartiba <_<

Link to comment
Share on other sites

Nee nevajaga, jo taa ir defineta konstante.

 

Nu es mēģināju debugot un koda vidu ieliku echo $_SESSION['auth'] . $_SESSION['expire']; un spiedu refresh. Un no 100 x man vienu reizi tie abi divi parādījās. Nesaprotu, to, ka sesija atrodas /tmp folderī bet php to nevar parādīt!

Edited by Gacha
Link to comment
Share on other sites

Hmm, taa man shkjiet ari bus ta klluda, jo izveidoju mazu testa lapu un taja viss stradaja.

 

Kur tieshi tad tas session_start() jaliek ? <_<

Man ir index lapa un ieksh taas login un vel tiek inkludota funkciju lapa. Kur tad jaliek tas session start ?

 

Zinu to, ka ja nebutu tas vis f-cijas, tad staradatu. Bet man vajag f-cijas

Edited by Gacha
Link to comment
Share on other sites

×
×
  • Create New...