rward Posted May 3, 2007 Share Posted May 3, 2007 Hi, I am wondering if anybody can help here. basically what i want to do is at the start of my site check if the sessions are set and if not set them. My problem is that on calling the following snippet of code it processes the first time but does not actually assign the var 'session_id' until after a refresh or hitting the home page link that first calls this function. Which results further down the line as two entrys into my database first one blank and second one with the 'session_id' var correctly. if (!isset($_SESSION['session_id'])) { session_start(); $_SESSION['session_id'] = $PHPSESSID; ...save to database the variable session_id.... } Regards Rob Link to comment https://forums.phpfreaks.com/topic/49775-session-problem/ Share on other sites More sharing options...
suzzane2020 Posted May 3, 2007 Share Posted May 3, 2007 place session_start at the very beginning of the script ..not in the condition Link to comment https://forums.phpfreaks.com/topic/49775-session-problem/#findComment-244169 Share on other sites More sharing options...
rward Posted May 3, 2007 Author Share Posted May 3, 2007 Yes I had tried this first and after different tests the condition was posted as previous but its the same effect. session_start(); if (!isset($_SESSION['session_id'])) { $_SESSION['session_id'] = $PHPSESSID; ...save to database the variable session_id.... } Link to comment https://forums.phpfreaks.com/topic/49775-session-problem/#findComment-244176 Share on other sites More sharing options...
scottybwoy Posted May 3, 2007 Share Posted May 3, 2007 Try $_SEESION['session_id'] = session_name(); Link to comment https://forums.phpfreaks.com/topic/49775-session-problem/#findComment-244189 Share on other sites More sharing options...
rward Posted May 3, 2007 Author Share Posted May 3, 2007 scottybwoy, This helps in the way that only one entry is saved to the DB until reloading the browser but the session ID itself is still not saved to the database or the variable 'session_id'. Could you elaborate on your answer. Cheers Rob Link to comment https://forums.phpfreaks.com/topic/49775-session-problem/#findComment-244329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.