|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
session id problem
Everytime I execute a session_start() command, a new session ID is generated. is this normal with PHP on Windows?
i need to have the same session ID to be able to track my variables right? - when I go from one page to another (say from a login page to a login confirmation page) I get different session IDs. the following is my setup: - Windows XP - PHP 4.3.1 for Windows - MySQL 3.23.55-nt |
|
#2
|
|||
|
|||
|
Append your links with the session id
PHP Code:
Or, you can use the constant SID PHP Code:
Or, if you are really really lazy - have PHP do it for you PHP Code:
Now, lets get to your problem. Your php ini file is set to have session.use_trans_sid = 0, or false - which means by default it will not attempt to re-write your urls. On the same note, session.use_cookies is set to 1 or true, meaning to track the user by means of setting a cookie. If php can't set a cookie on the clients machine, you need to carry the session info in the link(s) for php to know that there is an active session going on. Personally - I set 'session.use_trans_sid' to 0 or false in all of my applications as I prefer to write my own links. But, you can get a quick fix by enabling it as above. One other thing to note - make sure you have the ini_set() at the top of your script before starting the session...
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#3
|
|||
|
|||
|
Joe,
If I attach the session id to the links, does this mean I don't have to use the session_start() command if I go to another page? from what i understood in the PHP manual, i have to place a session_start() command in every page that needs to track the sessions. is my understanding correct? or do i just need to execute this command at the very start of the session? thanks, hec |
|
#4
|
|||
|
|||
|
Yes - you must still and always use session_start() at the top of your pages....
|
|
#5
|
|||
|
|||
|
ok - my other problem is in accessing the session variables i set in the previous pages.
correct me if i am wrong: if I need to set a session variable I use session_register() and then set the value of the variable like this: PHP Code:
and then in the following page I can access the variable by using $_SESSION['myvar']. my problem is I seem to be able to set the values for the variable but I could not access them anymore in the next pages - I get a "PHP Notice: Undefined index:myvar" error. |
|
#6
|
|||
|
|||
|
Ok - this is why it is essential to post your code on when looking for help.
session_register(), session_is_register(), session_unregister() Get rid of those functions - never refer to them, act like they are invisible as they will actually be invisible by ver 5 anyways. But until then, just ignore those functions. Now, to register a session variable, you would register it as so -> PHP Code:
To unregister the session variable -> PHP Code:
To check to see if it is registered -> PHP Code:
Remeber, do all of this after you have started the session.... ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > session id problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|