Tag Archives: session

PHP session_start() error? [duplicate]

Questions: Possible Duplicate: PHP headers already sent So I just joined Hostgator.com, and was wondering, why do I always get this error: Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/kapip/public_html/main/mainpage.php:5) in /home/kapip/public_html/main/mainpage.php on line 7 Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent… Read More »

Using PHP $_SESSION variable to store large amonts of data

Questions: I’m currently storing a fair amount of data in the $_SESSION variable. I’m doing this so I don’t need to keep accessing the database. Should I be worried about memory issues on a shared server? Can servers cope with large amounts of data stored in the $_SESSION variable? Answers:

Laravel TokenMismatchException database session

Questions: My $request->input(_token) is a mismatch of $request->session()->toke() when switching from file to database sessions. This is causing a CSRF TokenMismatchException. When switching back from database to file sessons driver the mismatch does not occur. Does anyone know why i get this mismatch and possibly how to resolve it? 🙂 What i have done: Using… Read More »

How to insert javascript value into the php session variable

Questions: I want to insert javascript value into the php session variable but inside the javascript function. Here is what I have tried and it is not working: function languageChange() { var lang = $(‘#websites1 option:selected’).val(); <?php $_SESSION[‘SESS_LANGUAGE’]?> = lang; alert(<?php echo $_SESSION[‘SESS_LANGUAGE’]?>); } Answers:

CodeIgniter Session Disappear Bug?

Questions: I am using CI 1.7.3 and here are my settings: $config[‘sess_cookie_name’] = ‘ci_session’; $config[‘sess_expiration’] = 0; $config[‘sess_encrypt_cookie’] = FALSE; $config[‘sess_use_database’] = TRUE; $config[‘sess_table_name’] = ‘sessions’; $config[‘sess_match_ip’] = FALSE; $config[‘sess_match_useragent’] = TRUE; $config[‘sess_time_to_update’] = 300; I cannot come up with steps that cause the session to expire, it just seems random and is very frustrating… Read More »

php session variable lost

Questions: I work with php5 and apache2 on my development machine. The production server is apparently similar. I have a script set_language.php that creates a session variable according to the language chosen: <?php session_start(); $back = $_SERVER[‘HTTP_REFERER’]; if (isset($_GET[‘lang’])) { if ($_GET[‘lang’] == ‘fr’) $_SESSION[‘lang’] = ‘fr’; else if ($_GET[‘lang’] == ‘en’) $_SESSION[‘lang’] = ‘en’;… Read More »

How to destroy the php session with one button

Questions: I’d like to make a simple form button which completely destroys the session when you click on it. I am just starting to use PHP for the first time, and do not see how I implement it into my HTML code. What I’d like is simply a form button which will clear the session… Read More »

Store it in Session or Query DB each page load?

Questions: Which is the better route to go? Should I store my object in session and pass it from page to page, or should I query the database each time the user migrates to another page in my web app? If I should store my object in session, how would I go about doing that?… Read More »

Why can't I use session_start() in my php script? It says headers are already sent

Questions: Here are the first few lines of my page: <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <?php include_once “dblogin.php”; session_start(); $loggedIn = 0; if(isset($_SESSION[“login”])) {$loggedIn = 1;} ?> I’m getting the following error: Cannot send session cookie – headers already sent by (output started at /usr/www/users/simpleof/index.php:2) in /usr/www/users/simpleof/index.php on line 2 From what… Read More »