Toon posts:

[PHP] SID werkt niet

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ey,

Ik heb een inlogscript met sessies gemaakt, en alles werkt perfect. Op één ding na. Ik wil de sessie naam bij elke URL meegeven, en dat wil niet lukken.
PHP:
1
2
3
<?
<a href="test.php?<? echo SID; ?>">
?>

werkt niet. De constante SID geeft alleen maar een lege waarde. Terwijl $session_id wel werkt. Maar SID is wat korter.

Hoe kan dit?

Ik draai PHP 4.0.3 btw (moet het ondersteunen volgens php.net).

Verwijderd

maak er dit van:

<?php
echo "<a href="test.php?sid=$SID">";
?>

je moet altijd $ voor een variable zetten, dus niet SID maar $SID

Verwijderd

Topicstarter
SID is een constante..

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 12-09 21:31

Janoz

Moderator Devschuur®

!litemod

Maar je bent wel de sid= tussen je php en je vraagteken vergeten :)

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


  • Nazgul
  • Registratie: Februari 2000
  • Laatst online: 11-10-2022

Nazgul

Digital Pizza Crew

Ik heb dit gevonden:

PHP is capable of doing this transparently when compiled with --enable-trans-sid. If you enable this option, relative URIs will be changed to contain the session id automatically. Alternatively, you can use the constant SID which is defined, if the client did not send the appropriate cookie. SID is either of the form session_name=session_id or is an empty string.

No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.


Verwijderd

Topicstarter
Letterlijk van:
http://www.php.net/manual/en/ref.session.php
Alternatively, you can use the constant SID which is defined, if the client did not send the appropriate cookie. SID is either of the form session_name=session_id or is an empty string.
PHP:
1
2
3
<?
To continue, <A HREF="nextpage.php?<?php echo SID?>">click here</A>
?>

Precies zoals ik het heb dus. Dat vetgedrukte gedeelte heb ik dus last van, maar het lijkt mij dat SID alleen leeg is als er geen sessie gestart is, en ik weet toch zeker dat dat wel zo is.

Verwijderd

Topicstarter
Ah thanx nazgul, dat had ik dus ff over het hoofd gezien! Mijn dank is groot :).

  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

session_start() in je php staan?

Doet iets met Cloud (MS/IBM)


Verwijderd

had niet gelezen dat het om een constante ging, mijn excuses :D

Verwijderd

Topicstarter
Op maandag 04 februari 2002 23:08 schreef Stoel het volgende:
had niet gelezen dat het om een constante ging, mijn excuses :D
Nou vooruit dan maar, tis je vergeven ;).
Pagina: 1