Welcome Guest, Not a member yet? Register   Sign In
  subdomain session and cookies problem
Posted by: El Forum - 11-11-2008, 02:35 PM - Replies (14)

[eluser]dexcell[/eluser]
Hi, i've been searching all over the forum but still cannot find a good answer about this problem.

Basically, the problem is session doesn't carry in another subdomain. (i suspect because of the cookies)

So, for example you login at localhost/login/, then open another page with different subdomain like username.localhost the session will create another session_id in the database, kinda like one session for one subdomain. so the username.localhost do not aware that you already logged in.

After i dig more, i found out the cookies might be the source of this problem.
because if the session doesn't find the cookies it will try to create new record in the database (i'm using sess_use_database = TRUE).

So i try to change the cookie_domain in config into ".localhost" (because i'm doing it in my local comp for developing)

Code:
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path'   =  Typically will be a forward slash
|
*/
$config['cookie_prefix']    = "";
$config['cookie_domain']    = ".localhost";
$config['cookie_path']        = "/";

But this make worse than previous, every time there is a request even in the same subdomain, session always create new session_id in the database,
after i check the log, it always doesn't found the cookies (A session cookie was not found)
and that's explain why session always create new session id.

So, does someone a way to solve this problem?
Please help.. I'm getting stuck..



Thank you.


  fix img helper into CI
Posted by: El Forum - 11-11-2008, 02:19 PM - No Replies

[eluser]XssLab[/eluser]
Hello boys,

this is my first topic on Code Igniter forum's community.

To use CI, I have been find a simple type of bug.

The img() helper is incomplete... don't generate the alt='' tab (and this is not compatible with W3C).

This is my personal version of img() function

Code:
if ( ! function_exists('img'))
{
    function img($src = '', $alt = 'default', $index_page = FALSE)
    {
        if ( ! is_array($src) )
        {
            $src = array('src' => $src);
        }

        $img = '<img';
        
        foreach ($src as $k=>$v)
        {

            if ($k == 'src' AND strpos($v, '://') === FALSE)
            {
                $CI =& get_instance();

                if ($index_page === TRUE)
                {
                    $img .= ' src="'.$CI->config->site_url($v).'" ';
                }
                else
                {
                    $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" ';
                }
            }
            else
            {
                $img .= " $k=\"$v\" ";
            }
        }

        $img .= 'alt="'.$alt.'" ';
        $img .= '/>';

        return $img;
    }
}

Good day!


  Authorization Question
Posted by: El Forum - 11-11-2008, 01:15 PM - Replies (5)

[eluser]Jesse Schutt[/eluser]
I'm not too sure how to ask this question, so here goes!

I am currently working on a backend/dashboard that I want to protect with a username/password login. Only a few people will need to access this area. Several of the auth systems I have looked at seem to be way more than I need. For example, I don't need to have the ability to register users through the site, so I don't want to spend the effort in that area yet.

Can you explain in plain english how this should work?

Thanks Much!

Jesse


  CI and js Form Validation
Posted by: El Forum - 11-11-2008, 10:53 AM - Replies (1)

[eluser]al404[/eluser]
is not clear to me if CI can validate form data only after submit or as some JS form validation before?

if not, can you tell me a plugin for inline ajax style validation?


  Problema com charset ao submeter form
Posted by: El Forum - 11-11-2008, 10:50 AM - No Replies

[eluser]Diego CODU[/eluser]
Ocorre um erro sempre que tento submeter um form, no qual um dos inputs contém caracteres latinos, como letras acentuadas.

O erro é esse:

A Database Error Occurred
Error Number: 1406

Data too long for column 'xxx' at row 1


Gostaria de saber como soluciona-lo...

-------- ENGLISH VERSION ----------------
There was a bug report always I try to submit a form that have one input field with a latin character, with accents for example.

This error following:


A Database Error Occurred
Error Number: 1406

Data too long for column 'xxx' at row 1


I'd like to solution it!

I'm sorry for my English, I'm from Brazil...


  Session problem
Posted by: El Forum - 11-11-2008, 10:36 AM - Replies (3)

[eluser]new developer[/eluser]
I simplfied my code as follows

Code:
&lt;?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }
    

    function index(){
    }
}

?&gt;

It still has problem. The error is
Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\CMS\system\application\controllers\welcome.php:22)

Filename: libraries/Session.php

Line Number: 662

IS there a way around this problem??


  Sesion already sent problem
Posted by: El Forum - 11-11-2008, 10:10 AM - Replies (3)

[eluser]new developer[/eluser]
I have a problem saying session headers already sent. I worked the same code on Wamp but i installed Xampp recently. It gives me an error. My code is really simple as below. Can anyone please help me rectify this.

Code:
&lt;?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }
    

    function index(){
    $data['main'] = 'adminLogin';
      $data['title']= 'Welcome to my first aplication';
    $this->load->vars($data);
    $this->load->view(dashboard);
    }

      function verifyMe(){
      if($this->input->post('username')){
      $u = $this->input->post('username');
      $p = $this->input->post('password');
      $this-> MAdmins-> verifyUser($u,$p);
    if ($_SESSION['userid'] > 0){
    redirect('admin/dashboard','refresh');
    }
    }
         $this-> session-> set_flashdata(error  , 'Login failed');
       $this->load->view(adminLogin);
      }
}

?&gt;


  Function set_value() not working as expected
Posted by: El Forum - 11-11-2008, 09:51 AM - Replies (44)

[eluser]beachbum[/eluser]
I have the following html/php & codeigniter in my view for my contact form:

Code:
&lt;input type='text' name='phone' id='phone' value="&lt;?php echo set_value('phone'); ?&gt;" /&gt;

I have used the set_value() function in all of the other fields in this form, and it works like a charm. However, it never works for this field, and I can't understand why it doesn't.

Incidentally, the "phone" field is the only field in the form (besides the submit button) for which I have not used any validation with the form_validation library. That is the only anamoly that I've been able to find, but the fact that I didn't set a validation rule for this field should not prevent the set_value() function from working, should it?

Thanks!

Contact form


  Flashdata persists to second request
Posted by: El Forum - 11-11-2008, 09:47 AM - Replies (2)

[eluser]beachbum[/eluser]
Hello,

I'm relatively new to Code Igniter and have been using it to perform some simple form processing. I may have made an error in my code that caused this problem, but I've been unable to find it so far.

This is my controller function, which takes the POSTed form data, validates it, and then sets either an "error" or a "success" message in the flashdata based on the outcome of the input validation.

However, the flashmessage does not appear until the second request after the form has been posted, and if the form has been posted more than once, the old flashdata persists. Can anyone please offer some advice? Thanks!

Code:
function send()
    {
         $data['title'] = 'Contact Us | American Retina Foundation';
        
          if ( $_POST['submit'] != '' )
          {
              $this->load->library( 'form_validation' );
              
              $this->form_validation->set_rules( 'first_name', 'First name', 'trim|required' );
               $this->form_validation->set_rules( 'last_name', 'Last name', 'trim|required' );
               $this->form_validation->set_rules( 'email', 'Email address', 'trim|required|valid_email' );
               $this->form_validation->set_rules( 'message', 'Message', 'trim|required' );
              
              if ( $this->form_validation->run() == FALSE )
              {
                   $this->session->set_flashdata( 'error', validation_errors() );
              }
              else
              {
                    // mail( $staff, $subject, $message, $headers );
                    
                    // insert contact record into db
                    $sender = array(
                                   'first_name'   => $this->input->post( 'first_name' ),
                                   'last_name'    => $this->input->post( 'last_name' ),
                                   'email'        => $this->input->post( 'email' ),
                                   'phone'        => $this->input->post( 'phone' ),
                                   'message'      => $this->input->post( 'message' ),
                                   'sent'         => NULL,
                                   'ip'           => $this->input->ip_address(),
                                   'user_agent'   => $this->input->user_agent()
                                );

                    $this->db->insert('tblContacts', $sender);

                   // display success notice
                   $this->session->set_flashdata( 'success', 'Thank you! Your message has been sent.' );
              }          
          }
        
         $data['section']              = 'contact';
        $data['content_for_layout']   = $this->load->view( 'contact/index', '', TRUE );
        $this->load->view( 'layouts/secondary', $data );
    }

Here is the form itself: Contact Form


  Image Problem!
Posted by: El Forum - 11-11-2008, 09:32 AM - Replies (3)

[eluser]Lazos[/eluser]
Hi. Maybe this forum is not the right one for this question. I hope somebody will answer though.

I have a script that resize and rotate images. I am using an iframe for viewing the images and I have small thumbnails for every image using the image manipulation class of CI. Below them I have small icons for rotating and resizing the image.

Anyway when I rotate something and even I have the refresh or location redirect inside the iframe images do not change to their new state after rotation. I need to refresh the iframe manually in order to see the changes.

Do you know how to fix this problem?
(Is it because the browser is caching images and because even I rotate or resize I keep the same name browser still things is the same image?)

I hope somebody can help me.
Thanks.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Showing pdf on browser
by kenjis
15 minutes ago
directory structure
by badger
33 minutes ago
Redirect with error vali...
by pippuccio76
40 minutes ago
[4.5.1] Disabling the deb...
by kenjis
46 minutes ago
Pass custom variables to ...
by InsiteFX
3 hours ago
problem with textarea
by InsiteFX
3 hours ago
How to run a single seede...
by kenjis
8 hours ago
Codeigniter 4 extend core...
by kenjis
8 hours ago
blocked by CORS policy
by kenjis
9 hours ago
[CodeIgniter 4 on IIS 10]...
by Bosborne
Yesterday, 12:33 PM

Forum Statistics
» Members: 84,242
» Latest member: lichbongdaco
» Forum threads: 77,553
» Forum posts: 375,872

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB