I know that session_start()
is required at the top of every page to continue a session. Is it also required to declare the session_id()
at the top of every page as well or does session_start()
remember the session_id()
for the duration of the session from the first page?
Asked
Active
Viewed 51 times
0
-
Do you need to change the default session ID? What happens when you omit session_id()? – Álvaro González May 20 '18 at 10:41
-
I dont need to change it. I just want to know if the session will remember the id or if I have to set it for every page? – May 20 '18 at 10:46
-
Then, I'll just drop a generic tip: if there's a function to do X and you don't need X, you probably don't need the function. – Álvaro González May 20 '18 at 10:50
-
Let me ask this a different way. Does session_start remember the current session_id if leave the page and go to another page? – May 20 '18 at 10:55
-
@Adam yes it remember everything that you save in your session. – Zaheer Ahmad May 20 '18 at 11:04
-
@zaheer Thanks much. – May 20 '18 at 11:13
-
Are you interested something like this ? https://stackoverflow.com/questions/40801843/php-how-to-manage-multiple-session-in-same-browser-using-cookies – TahaG May 20 '18 at 11:13
-
Possible duplicate of [Should I regenerate\_session\_id on every page?](https://stackoverflow.com/questions/7180559/should-i-regenerate-session-id-on-every-page) – Tom May 20 '18 at 11:19
1 Answers
0
Edit: an update to your actual question:
page1.php:
<?php
session_id('test');
session_start();
page2.php
<?php
session_start();
var_dump(session_id());
When you first open page1.php and after that page2.php the output of page2.php will be:
string(4) "test"

Thijn
- 165
- 1
- 8
-
I was just curious if I have the session_id function on every page. The purpose for this is I want to separate sessions for a web page being used by multiple users on the same computer, such as have two facebook accounts open at the same time on one computer – May 20 '18 at 11:04
-
-