Jump to content
php.lv forumi

session_start();


tiy

Recommended Posts

kads id ir pieskirts shinivarianta un ka pareizi ir pieskirt id, vai session dati bus ka globa lie vai vinus vajaga parsutit no vienas lapas uz otru. Gribetos zinat vai var ka globalos izveidot un ka?

 

<?php

// page1.php

 

session_start();

 

echo 'Welcome to page #1';

 

$_SESSION['favcolor'] = 'green';

$_SESSION['animal'] = 'cat';

$_SESSION['time'] = time();

 

// Works if session cookie was accepted

echo '<br /><a href="page2.php">page 2</a>';

 

// Or maybe pass along the session id, if needed

echo '<br /><a href="page2.php?' . SID . '">page 2</a>';

 

?>

Link to comment
Share on other sites

Ja es uz vienas lapas uzrakstu

 

<?php

session_start();

$_SESSION['favcolor'] = 'green';

?> , bet uzcitas es jau varu rakstit

 

<?php

$color=$_SESSION['favcolor']; //un $color=green;

 

// vai es te talak varu turpinat pashu saitu

 

ehco" <html><head>..... ";

 

?>

Edited by tiy
Link to comment
Share on other sites

tiy--> pats php kods var atrasties jebkuraa lapas vietaa iznjemot seesion_start()

un ja ir nepiechieshams redirekteet uz citu lapu - tad tas Pirms jebkaadas izvades

 

<?php

session_start()

?>

HTML tekstc

<?php

echo $katkaads_mainiigasi;

?>

turpinam html

<?php

atkal koda gabals

?>

 

P.S. dazreiz vajag parbaudiit vai vispaar sesiju starteet:

<?php

if (bla bla)

{

sesiion_start();

}

else

{

sesiju nelaizam

}

?>

Link to comment
Share on other sites

<html>

....

 

..

<?php

echo ...

if (.....)

{

session_start();

....

}

 

?>

</body>

</html>

 

Es nezinu ko, bet es funkcija izsaucu session_start ,tad pieskiru datus un viss it ka strada.

Vai var rasties kadas problemas.

Link to comment
Share on other sites

×
×
  • Create New...