Re: session problem
| From: | pag | Date: | Sat, 26 Apr 2003 01:09:19 +0000 |
| Subject: | Re: session problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145327@lists.php.net to get a copy of this message | ||
this problem is kinda urgent : \
"Pag" <pag@rising-stars.de> schrieb im Newsbeitrag
news:20030425185918.76014.qmail@pb1.pair.com...
> Hi all,
> i've got a problem with the sessions. I use this code since 1,5 years now
> and there wasn't a problem before. Now my hoster updated their webbie to
the
> new php version and my sessions doesnt work anymore.
>
> index.php: i've changed the session_register to $_session['User']; but
it
> didnt change anything... still the same problem.
> check_uids();
> if(isset($cookie_uid)) {
> session_id($cookie_uid);
> }
> session_start();
> setcookie('cookie_uid',session_id(),time()+900);
> if(!session_is_registered('USER')) {
> session_register('USER');
> }
> $uid = session_id();
> if(check_uid($uid)) {
> update_uid($uid);
> }
> else {
> add_online($uid);
> set_hits();
> }
>
> if(!($USER['id'] > '0')) {
> if(isset($cookie_name) and isset($cookie_pass)) {
> if($i=check_login($cookie_name, $cookie_pass)) {
> $USER = get_user($i);
> set_online($uid,$i);
> }
> else {
> $USER =
> array('id'=>'0','name'=>'anonym','level'=>'0');
> }
> }
> else {
> if(get_online($uid) == '0') {
> $USER =
> array('id'=>'0','name'=>'anonym','level'=>'0');
> }
> else {
> $USER = get_user(get_online($uid));
> }
>
> session.php :
> <?
> session_start();
> $_SESSION["zaehler"];
> $zaehler++;
> echo $zaehler."<br>";
> echo session_id()."<br>";
> echo strlen(session_id())."<br>";
> echo "<a href=\"session.php?".SID."\">weiter</a>";
> ?>
>
> and this are my functions with the uid etc:
> function check_uid($uid) {
> global $sql_id;
> $result = mysql_query("SELECT id FROM rs_online WHERE
> uid='$uid'",$sql_id);
> if($row = mysql_fetch_array($result)) {
> return true;
> }
> return false;
> }
> function check_uids() {
> global $sql_id;
> $time = time_unix_sql(time()-900);
> $result = mysql_query("DELETE FROM rs_online WHERE
> timeout<'$time'",$sql_id);
> return true;
> }
> function update_uid($uid) {
> global $sql_id;
> $result = mysql_query("UPDATE rs_online SET timeout=NULL WHERE
> uid='$uid'",$sql_id);
> return $id;
>
>
> The problem is: when i login to the page i'm logged in as 'pag' when with
> the old code (session_register) i left the page and when i came back
> "welcome , last login 01.01 - 01:00AM" normally it's welcome pag, . with
the
> new code $_session: when i click on a link on my page i immediately get
this
> welcome , last login 01.01 - 01:00AM' ... so im not logged in anymore :\
> I didn't change anything on this code since 1,5 year(s).
> I hope anyone of you is able to help me.
> best regards,
> pag
>
>