Im a new programmer for php. when I programming with session I got errors. Here the question. I make small code to gte seeeion id. but when I reload the page it appear different id at diffrerent times. This is my code <?php session_start(); echo "<p>Your session ID is ".session_id().".</p>"; ?> But I have heard about that session id cannot change when reload the page. How can I solve this. Thanks de_oracle
Hi! Suppose you have start the session and suppose the sesion id is 'd33ea4152eda39aba6c0cf41bb4e67b2' now again when you call session_start(). before session_start() write a script session_id('d33ea4152eda39aba6c0cf41bb4e67b2'); You need to pass session id in query string or whatever... session_id('d33ea4152eda39aba6c0cf41bb4e67b2'); session_start();
Thanks. But I didnt get it. suppose that when I run the page first time session id is d33ea4152eda39aba6c0cf41bb4e67b2. But when the page reload it gets different id. So I cannot use user tracking things in my code.In browser I have enable cookies.
I think during execution of ur page the session is started and expired somewhree in same (or incudeed) file. and when you reload the page new session starts with new id and expired.......... So check that have you wriiten any scripts on same (or included) file which destroy your running session. If yes then remove a scripts which destroy a session upto when you want to use same session. in your code in last line check whether your started session is exists or not. If not than you will continue with your prb otherwise the prb is somethingelse.