• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Group data in a multidimensional array based on two columns

using random function but it's displaying duplicates

how to remove %20 in the url in php

Post Form Data To phpmyadmin Database

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Assign output of PHP function to a variable

Issue with laravel eloquent model property

How to submit the custom form data in database in WordPress without plugin using ajax?

Adding hreflang tags automatically in WordPress subdirectory multisite

Vimeo API: how to save a vimeo into a subfolder?

Laravel post contact form giving me error 419

301 Redirect to remove query string on homepage only

find in set in laravel ? example

Laravel Mix Uncaught ReferenceError: $ is not defined

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

About Contact Privacy policy Terms and conditions