1

i want to know if after i store a value in the $_SESSION, can i access it several times in different files?? for example i stored a value: $_SESSION['login']="Fred"

can i access that value in different files in different times??

for example: b.php

<?php
session_start();
$uname=$_SESSION['login'];
?>

c.php

<?php
session_start();
$uname=$_SESSION['login'];
?>

d.php

<?php
session_start();
$uname=$_SESSION['login'];
?>

is this possible??

2
  • 1
    yes it is possible .what is your problem?? Aug 27, 2012 at 11:22
  • if you it is not working at any instance of your code check the session storage paths for your files Aug 27, 2012 at 11:45

3 Answers 3

3

Yes, It is possible.

See PHP Session with details.

Note: PHP Session are meant to be that way, Unless you desrtoy it OR they are expired.

0
1

Yes. The $_SESSION variable will persist between PHP files, unless it expires or you destroy the session. In the most common server configurations this requires a cookie to save the session ID, so make sure those are enabled.

0
0

Yes your session will be available for each request from the same browser instance. if some where you are not getting it may be there session storage path is different for those files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.