jeeva Posted January 29, 2007 Share Posted January 29, 2007 Y should i have session_start() to get session veriables?wt will happen when i start the session? Link to comment https://forums.phpfreaks.com/topic/36145-session_start/ Share on other sites More sharing options...
pikemsu28 Posted January 29, 2007 Share Posted January 29, 2007 http://www.w3schools.com/php/php_sessions.asp"A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application." Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171648 Share on other sites More sharing options...
chronister Posted January 29, 2007 Share Posted January 29, 2007 session_start(); declares that you are starting a session. If you try to use session variables without starting a session it will most likely turn out that your variables will not be available to you because a session has not been registered. (Unless, session.auto_start is set to 1 in php.ini)[quote author=jeeva link=topic=124499.msg515907#msg515907 date=1170051171]wt will happen when i start the session?[/quote]Is what happens when you start a session, is that it looks for an active session for this particular user and if no session is active, then it starts a new one. You can call session_start() on all your pages and never use a session var and no harm will be done. Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171651 Share on other sites More sharing options...
twilightnights Posted January 29, 2007 Share Posted January 29, 2007 What happens if you use more than 1 session_start() in code? Like I have 1 that keeps track of if a user voted on an object, what if I use a session then to keep track of them being logged in? Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171661 Share on other sites More sharing options...
pikemsu28 Posted January 29, 2007 Share Posted January 29, 2007 you only need one session_start() per page.you then store the variables in the session$_SESSION['user'] = $_POST['user'];code.........more code.....$_SESSION['vote'] = $_POST['vote'];the session_start() is required before any html and allows the script to store variables Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171666 Share on other sites More sharing options...
chronister Posted January 29, 2007 Share Posted January 29, 2007 [quote author=pikemsu28 link=topic=124499.msg515929#msg515929 date=1170055435]the session_start() is required before any html and allows the script to store variables[/quote]This is really important. If you don't place the session_start() at the very beginning of a file, before the <html> tag, you are probably going to get header errors. Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171671 Share on other sites More sharing options...
jeeva Posted January 29, 2007 Author Share Posted January 29, 2007 thanks for all............. Link to comment https://forums.phpfreaks.com/topic/36145-session_start/#findComment-171679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.